summaryrefslogtreecommitdiff
path: root/src/version_usage.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-09-14 12:43:32 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2009-09-14 12:43:32 +0000
commitaefb035bb1922f1f057faf9a99dcdb36117bd4dc (patch)
treeb22f78c91e95ddc065ee2f765e886289b4c10286 /src/version_usage.cc
parentaa4bac65d9165b5612b0e722fbb40c3029f65214 (diff)
2009-09-14 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Help category now starts with "#" to distinguish a category from keyword search. For example, "http" categroy is now "#http". You can type "--help=#http" to get explanation of options related to http. If '#' is omitted, then the argument is treated as a keyword and aria2 searches options whose name includes the keyword and print matched ones. For example, "--help=http" will show options whose name includes "http". * src/OptionHandlerFactory.cc * src/help_tags.h * src/usage_text.h * src/version_usage.cc
Diffstat (limited to 'src/version_usage.cc')
-rw-r--r--src/version_usage.cc48
1 files changed, 25 insertions, 23 deletions
diff --git a/src/version_usage.cc b/src/version_usage.cc
index 674ee631..ad7d51b1 100644
--- a/src/version_usage.cc
+++ b/src/version_usage.cc
@@ -33,6 +33,11 @@
*/
/* copyright --> */
#include "common.h"
+
+#include <iostream>
+#include <iterator>
+#include <algorithm>
+
#include "SharedHandle.h"
#include "a2io.h"
#include "FeatureConfig.h"
@@ -44,9 +49,7 @@
#include "StringFormat.h"
#include "OptionParser.h"
#include "OptionHandler.h"
-#include <iostream>
-#include <iterator>
-#include <algorithm>
+#include "Util.h"
namespace aria2 {
@@ -76,27 +79,10 @@ void showUsage(const std::string& keyword, const OptionParser& oparser) {
std::cout << StringFormat(_("Usage: %s [OPTIONS] [URL | TORRENT_FILE |"
" METALINK_FILE]..."), PACKAGE_NAME) << "\n"
<< "\n";
-
- std::deque<SharedHandle<OptionHandler> > handlers =
- keyword == V_ALL ? oparser.findAll():oparser.findByTag(keyword);
- if(handlers.empty()) {
+ if(Util::startsWith(keyword, "#")) {
std::deque<SharedHandle<OptionHandler> > handlers =
- oparser.findByNameSubstring(keyword);
- if(!handlers.empty()) {
- std::cout << StringFormat(_("Printing options whose name includes"
- " '%s'."), keyword.c_str())
- << "\n"
- << _("Options:") << "\n";
- std::copy(handlers.begin(), handlers.end(),
- std::ostream_iterator<SharedHandle<OptionHandler> >
- (std::cout, "\n\n"));
- } else {
- std::cout << StringFormat(_("No help category or option name matching"
- " with '%s'."), keyword.c_str())
- << "\n" << oparser.findByName("help") << "\n";
- }
- } else {
- if(keyword == V_ALL) {
+ keyword == TAG_ALL ? oparser.findAll():oparser.findByTag(keyword);
+ if(keyword == TAG_ALL) {
std::cout << _("Printing all options.");
} else {
std::cout << StringFormat(_("Printing options tagged with '%s'."),
@@ -113,6 +99,22 @@ void showUsage(const std::string& keyword, const OptionParser& oparser) {
std::copy(handlers.begin(), handlers.end(),
std::ostream_iterator<SharedHandle<OptionHandler> >
(std::cout, "\n\n"));
+ } else {
+ std::deque<SharedHandle<OptionHandler> > handlers =
+ oparser.findByNameSubstring(keyword);
+ if(!handlers.empty()) {
+ std::cout << StringFormat(_("Printing options whose name includes"
+ " '%s'."), keyword.c_str())
+ << "\n"
+ << _("Options:") << "\n";
+ std::copy(handlers.begin(), handlers.end(),
+ std::ostream_iterator<SharedHandle<OptionHandler> >
+ (std::cout, "\n\n"));
+ } else {
+ std::cout << StringFormat(_("No option matching with '%s'."),
+ keyword.c_str())
+ << "\n" << oparser.findByName("help") << "\n";
+ }
}
if(keyword == TAG_BASIC) {