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
pull/1/head
Tatsuhiro Tsujikawa 2009-09-14 12:43:32 +00:00
parent aa4bac65d9
commit aefb035bb1
5 changed files with 59 additions and 41 deletions

View File

@ -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

View File

@ -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);

View File

@ -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_

View File

@ -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 \

View File

@ -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) {