summaryrefslogtreecommitdiff
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
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
-rw-r--r--ChangeLog14
-rw-r--r--src/OptionHandlerFactory.cc5
-rw-r--r--src/help_tags.h21
-rw-r--r--src/usage_text.h12
-rw-r--r--src/version_usage.cc48
5 files changed, 59 insertions, 41 deletions
diff --git a/ChangeLog b/ChangeLog
index 2b717015..2b886b81 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+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
+
2009-09-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Documented missing experimental tag and newly added xml-rpc tag in
diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc
index f763657f..a46d88cb 100644
--- a/src/OptionHandlerFactory.cc
+++ b/src/OptionHandlerFactory.cc
@@ -1266,7 +1266,7 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
TAG_BASIC,
StringFormat
("%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, "
- "all",
+ "%s",
TAG_BASIC,
TAG_ADVANCED,
TAG_HTTP,
@@ -1276,7 +1276,8 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
TAG_BITTORRENT,
TAG_XML_RPC,
TAG_EXPERIMENTAL,
- TAG_HELP).str(),
+ TAG_HELP,
+ TAG_ALL).str(),
OptionHandler::OPT_ARG,
'h'));
op->addTag(TAG_BASIC);
diff --git a/src/help_tags.h b/src/help_tags.h
index de1c2097..860a8c0c 100644
--- a/src/help_tags.h
+++ b/src/help_tags.h
@@ -35,15 +35,16 @@
#ifndef _D_HELP_TAGS_H_
#define _D_HELP_TAGS_H_
-#define TAG_BASIC "basic"
-#define TAG_ADVANCED "advanced"
-#define TAG_HTTP "http"
-#define TAG_HTTPS "https"
-#define TAG_FTP "ftp"
-#define TAG_METALINK "metalink"
-#define TAG_BITTORRENT "bittorrent"
-#define TAG_XML_RPC "xml-rpc"
-#define TAG_EXPERIMENTAL "experimental"
-#define TAG_HELP "help"
+#define TAG_BASIC "#basic"
+#define TAG_ADVANCED "#advanced"
+#define TAG_HTTP "#http"
+#define TAG_HTTPS "#https"
+#define TAG_FTP "#ftp"
+#define TAG_METALINK "#metalink"
+#define TAG_BITTORRENT "#bittorrent"
+#define TAG_XML_RPC "#xml-rpc"
+#define TAG_EXPERIMENTAL "#experimental"
+#define TAG_HELP "#help"
+#define TAG_ALL "#all"
#endif // _D_HELP_TAGS_H_
diff --git a/src/usage_text.h b/src/usage_text.h
index a7af5da5..3305bc09 100644
--- a/src/usage_text.h
+++ b/src/usage_text.h
@@ -374,13 +374,13 @@ _(" --metalink-enable-unique-protocol=true|false If true is given and several\n"
#define TEXT_VERSION \
_(" -v, --version Print the version number and exit.")
#define TEXT_HELP \
-_(" -h, --help[=CATEGORY] Print usage and exit.\n"\
+_(" -h, --help[=CATEGORY|KEYWORD] Print usage and exit.\n"\
" The help messages are classified in several\n"\
- " categories. For example, type \"--help=http\" for\n"\
- " detailed explanation for the options related to\n"\
- " http. If no matching category is found, search\n"\
- " option name using a given word in middle match\n"\
- " and print the result.")
+ " categories. A category starts with '#'. For\n"\
+ " example, type \"--help=#http\" to get the usage\n"\
+ " for the options related to http. If non-category\n"\
+ " keyword is given, print the usage of the options\n"\
+ " whose name includes given keyword.")
#define TEXT_NO_CONF \
_(" --no-conf Disable loading aria2.conf file.")
#define TEXT_CONF_PATH \
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) {