From aefb035bb1922f1f057faf9a99dcdb36117bd4dc Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 14 Sep 2009 12:43:32 +0000 Subject: 2009-09-14 Tatsuhiro Tsujikawa 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 --- src/version_usage.cc | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) (limited to 'src/version_usage.cc') 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 +#include +#include + #include "SharedHandle.h" #include "a2io.h" #include "FeatureConfig.h" @@ -44,9 +49,7 @@ #include "StringFormat.h" #include "OptionParser.h" #include "OptionHandler.h" -#include -#include -#include +#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 > handlers = - keyword == V_ALL ? oparser.findAll():oparser.findByTag(keyword); - if(handlers.empty()) { + if(Util::startsWith(keyword, "#")) { std::deque > 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 > - (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 > (std::cout, "\n\n")); + } else { + std::deque > 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 > + (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) { -- cgit