diff options
-rw-r--r-- | apt-private/private-cmndline.cc | 30 | ||||
-rw-r--r-- | apt-private/private-cmndline.h | 1 | ||||
-rw-r--r-- | cmdline/apt-cache.cc | 16 | ||||
-rw-r--r-- | cmdline/apt-cdrom.cc | 16 | ||||
-rw-r--r-- | cmdline/apt-config.cc | 15 | ||||
-rw-r--r-- | cmdline/apt-extracttemplates.cc | 5 | ||||
-rw-r--r-- | cmdline/apt-get.cc | 13 | ||||
-rw-r--r-- | cmdline/apt-helper.cc | 17 | ||||
-rw-r--r-- | cmdline/apt-internal-solver.cc | 2 | ||||
-rw-r--r-- | cmdline/apt-mark.cc | 14 | ||||
-rw-r--r-- | cmdline/apt-sortpkgs.cc | 7 | ||||
-rw-r--r-- | cmdline/apt.cc | 14 | ||||
-rw-r--r-- | ftparchive/apt-ftparchive.cc | 7 |
13 files changed, 44 insertions, 113 deletions
diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc index d80168fda..348b698ca 100644 --- a/apt-private/private-cmndline.cc +++ b/apt-private/private-cmndline.cc @@ -362,6 +362,25 @@ std::vector<CommandLine::Args> getCommandArgs(APT_CMD const Program, char const /*}}}*/ #undef CmdMatches #undef addArg +static bool ShowCommonHelp(APT_CMD const Binary, CommandLine &CmdL, aptDispatchWithHelp const * Cmds)/*{{{*/ +{ + std::cout << PACKAGE << " " << PACKAGE_VERSION << " (" << COMMON_ARCH << ")" << std::endl; + if (_config->FindB("version") == true && Binary != APT_CMD::APT_GET) + return true; + return ShowHelp(CmdL, Cmds); +} + /*}}}*/ +void ShowHelpListCommands(aptDispatchWithHelp const * Cmds) /*{{{*/ +{ + std::cout << _("Commands:") << std::endl; + for (; Cmds->Handler != nullptr; ++Cmds) + { + if (Cmds->Help == nullptr) + continue; + std::cout << " " << Cmds->Match << " - " << Cmds->Help << std::endl; + } +} + /*}}}*/ static void BinarySpecificConfiguration(char const * const Binary) /*{{{*/ { std::string const binary = flNotDir(Binary); @@ -397,6 +416,11 @@ std::vector<CommandLine::Dispatch> ParseCommandLine(CommandLine &CmdL, APT_CMD c std::vector<aptDispatchWithHelp> const CmdsWithHelp = GetCommands(); std::vector<CommandLine::Dispatch> Cmds; + if (CmdsWithHelp.empty() == false) + { + CommandLine::Dispatch const help = { "help", [](CommandLine &){return false;} }; + Cmds.push_back(std::move(help)); + } for (auto const& cmd : CmdsWithHelp) Cmds.push_back({cmd.Match, cmd.Handler}); @@ -414,7 +438,7 @@ std::vector<CommandLine::Dispatch> ParseCommandLine(CommandLine &CmdL, APT_CMD c (Sys != NULL && pkgInitSystem(*_config, *Sys) == false)) { if (_config->FindB("version") == true) - ShowHelp(CmdL, CmdsWithHelp.data()); + ShowCommonHelp(Binary, CmdL, CmdsWithHelp.data()); _error->DumpErrors(); exit(100); @@ -424,12 +448,12 @@ std::vector<CommandLine::Dispatch> ParseCommandLine(CommandLine &CmdL, APT_CMD c if (_config->FindB("help") == true || _config->FindB("version") == true || (CmdL.FileSize() > 0 && strcmp(CmdL.FileList[0], "help") == 0)) { - ShowHelp(CmdL, CmdsWithHelp.data()); + ShowCommonHelp(Binary, CmdL, CmdsWithHelp.data()); exit(0); } if (Cmds.empty() == false && CmdL.FileSize() == 0) { - ShowHelp(CmdL, CmdsWithHelp.data()); + ShowCommonHelp(Binary, CmdL, CmdsWithHelp.data()); exit(1); } return Cmds; diff --git a/apt-private/private-cmndline.h b/apt-private/private-cmndline.h index ac17e2e8a..6a6885a33 100644 --- a/apt-private/private-cmndline.h +++ b/apt-private/private-cmndline.h @@ -32,6 +32,7 @@ struct aptDispatchWithHelp std::vector<aptDispatchWithHelp> GetCommands(); bool ShowHelp(CommandLine &CmdL, aptDispatchWithHelp const * Cmds); +APT_PUBLIC void ShowHelpListCommands(aptDispatchWithHelp const * Cmds); APT_PUBLIC std::vector<CommandLine::Dispatch> ParseCommandLine(CommandLine &CmdL, APT_CMD const Binary, Configuration * const * const Cnf, pkgSystem ** const Sys, int const argc, const char * argv[]); APT_PUBLIC unsigned short DispatchCommandLine(CommandLine &CmdL, std::vector<CommandLine::Dispatch> const &Cmds); diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index 50af3f329..4e8a51583 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -1524,26 +1524,14 @@ static bool GenCaches(CommandLine &) /*}}}*/ bool ShowHelp(CommandLine &, aptDispatchWithHelp const * Cmds) /*{{{*/ { - ioprintf(cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH); - - if (_config->FindB("version") == true) - return true; - std::cout << _("Usage: apt-cache [options] command\n" " apt-cache [options] show pkg1 [pkg2 ...]\n" "\n" "apt-cache is a low-level tool used to query information\n" "from APT's binary cache files\n") - << std::endl - << _("Commands:") << std::endl; - for (; Cmds->Handler != nullptr; ++Cmds) - { - if (Cmds->Help == nullptr) - continue; - std::cout << " " << Cmds->Match << " - " << Cmds->Help << std::endl; - } - + << std::endl; + ShowHelpListCommands(Cmds); std::cout << std::endl << _("Options:\n" " -h This help text.\n" diff --git a/cmdline/apt-cdrom.cc b/cmdline/apt-cdrom.cc index 699cc550c..00895863b 100644 --- a/cmdline/apt-cdrom.cc +++ b/cmdline/apt-cdrom.cc @@ -205,26 +205,14 @@ static bool DoIdent(CommandLine &) /*}}}*/ bool ShowHelp(CommandLine &, aptDispatchWithHelp const * Cmds) /*{{{*/ { - ioprintf(cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH); - - if (_config->FindB("version") == true) - return true; - std::cout << _("Usage: apt-cdrom [options] command\n" "\n" "apt-cdrom is a tool to add CDROM's to APT's source list. The\n" "CDROM mount point and device information is taken from apt.conf,\n" "udev and /etc/fstab.\n") - << std::endl - << _("Commands:") << std::endl; - for (; Cmds->Handler != nullptr; ++Cmds) - { - if (Cmds->Help == nullptr) - continue; - std::cout << " " << Cmds->Match << " - " << Cmds->Help << std::endl; - } - + << std::endl; + ShowHelpListCommands(Cmds); std::cout << std::endl << _("Options:\n" " -h This help text\n" diff --git a/cmdline/apt-config.cc b/cmdline/apt-config.cc index 47e37c2f7..eb096440a 100644 --- a/cmdline/apt-config.cc +++ b/cmdline/apt-config.cc @@ -78,23 +78,12 @@ static bool DoDump(CommandLine &CmdL) /*}}}*/ bool ShowHelp(CommandLine &, aptDispatchWithHelp const * Cmds) /*{{{*/ { - ioprintf(cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH); - if (_config->FindB("version") == true) - return true; - std::cout << _("Usage: apt-config [options] command\n" "\n" "apt-config is a simple tool to read the APT config file\n") - << std::endl - << _("Commands:") << std::endl; - for (; Cmds->Handler != nullptr; ++Cmds) - { - if (Cmds->Help == nullptr) - continue; - std::cout << " " << Cmds->Match << " - " << Cmds->Help << std::endl; - } - + << std::endl; + ShowHelpListCommands(Cmds); std::cout << std::endl << _("Options:\n" " -h This help text.\n" diff --git a/cmdline/apt-extracttemplates.cc b/cmdline/apt-extracttemplates.cc index 1b16542fe..b63f2ff16 100644 --- a/cmdline/apt-extracttemplates.cc +++ b/cmdline/apt-extracttemplates.cc @@ -217,11 +217,6 @@ bool DebFile::ParseInfo() /*}}}*/ bool ShowHelp(CommandLine &, aptDispatchWithHelp const *) /*{{{*/ { - ioprintf(std::cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH); - - if (_config->FindB("version") == true) - return true; - cout << _("Usage: apt-extracttemplates file1 [file2 ...]\n" "\n" diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 69b12b2c7..474ed3159 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1528,8 +1528,6 @@ static bool DoIndexTargets(CommandLine &CmdL) /*}}}*/ bool ShowHelp(CommandLine &, aptDispatchWithHelp const * Cmds) /*{{{*/ { - ioprintf(cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH); - if (_config->FindB("version") == true) { cout << _("Supported modules:") << endl; @@ -1580,15 +1578,8 @@ bool ShowHelp(CommandLine &, aptDispatchWithHelp const * Cmds) /*{{{*/ "apt-get is a simple command line interface for downloading and\n" "installing packages. The most frequently used commands are update\n" "and install.\n") - << std::endl - << _("Commands:") << std::endl; - for (; Cmds->Handler != nullptr; ++Cmds) - { - if (Cmds->Help == nullptr) - continue; - std::cout << " " << Cmds->Match << " - " << Cmds->Help << std::endl; - } - + << std::endl; + ShowHelpListCommands(Cmds); std::cout << std::endl << _("Options:\n" " -h This help text.\n" diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc index b0c1ddacf..be6c2881a 100644 --- a/cmdline/apt-helper.cc +++ b/cmdline/apt-helper.cc @@ -107,26 +107,13 @@ static bool DoSrvLookup(CommandLine &CmdL) /*{{{*/ /*}}}*/ bool ShowHelp(CommandLine &, aptDispatchWithHelp const * Cmds) /*{{{*/ { - ioprintf(std::cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH); - - if (_config->FindB("version") == true) - return true; - std::cout << _("Usage: apt-helper [options] command\n" " apt-helper [options] download-file uri target-path\n" "\n" "apt-helper is a internal helper for apt\n") - << std::endl - << _("Commands:") << std::endl; - - for (; Cmds->Handler != nullptr; ++Cmds) - { - if (Cmds->Help == nullptr) - continue; - std::cout << " " << Cmds->Match << " - " << Cmds->Help << std::endl; - } - + << std::endl; + ShowHelpListCommands(Cmds); std::cout << std::endl << _("This APT helper has Super Meep Powers.") << std::endl; return true; diff --git a/cmdline/apt-internal-solver.cc b/cmdline/apt-internal-solver.cc index 28989f6cd..ae8c08bba 100644 --- a/cmdline/apt-internal-solver.cc +++ b/cmdline/apt-internal-solver.cc @@ -43,8 +43,6 @@ bool ShowHelp(CommandLine &, aptDispatchWithHelp const *) /*{{{*/ { - ioprintf(std::cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH); - std::cout << _("Usage: apt-internal-solver\n" "\n" diff --git a/cmdline/apt-mark.cc b/cmdline/apt-mark.cc index d02e80beb..b06fcc0cc 100644 --- a/cmdline/apt-mark.cc +++ b/cmdline/apt-mark.cc @@ -282,23 +282,13 @@ static bool ShowSelection(CommandLine &CmdL) /*{{{*/ /*}}}*/ bool ShowHelp(CommandLine &, aptDispatchWithHelp const * Cmds) /*{{{*/ { - ioprintf(std::cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH); - std::cout << _("Usage: apt-mark [options] {auto|manual} pkg1 [pkg2 ...]\n" "\n" "apt-mark is a simple command line interface for marking packages\n" "as manually or automatically installed. It can also list marks.\n") - << std::endl - << _("Commands:") << std::endl; - - for (; Cmds->Handler != nullptr; ++Cmds) - { - if (Cmds->Help == nullptr) - continue; - std::cout << " " << Cmds->Match << " - " << Cmds->Help << std::endl; - } - + << std::endl; + ShowHelpListCommands(Cmds); std::cout << std::endl << _("Options:\n" " -h This help text.\n" diff --git a/cmdline/apt-sortpkgs.cc b/cmdline/apt-sortpkgs.cc index b5a2c12df..f9aa7d728 100644 --- a/cmdline/apt-sortpkgs.cc +++ b/cmdline/apt-sortpkgs.cc @@ -134,11 +134,7 @@ static bool DoIt(string InFile) /*}}}*/ bool ShowHelp(CommandLine &, aptDispatchWithHelp const *) /*{{{*/ { - ioprintf(std::cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH); - if (_config->FindB("version") == true) - return true; - - cout << + std::cout << _("Usage: apt-sortpkgs [options] file1 [file2 ...]\n" "\n" "apt-sortpkgs is a simple tool to sort package files. The -s option is used\n" @@ -149,7 +145,6 @@ bool ShowHelp(CommandLine &, aptDispatchWithHelp const *) /*{{{*/ " -s Use source file sorting\n" " -c=? Read this configuration file\n" " -o=? Set an arbitrary configuration option, eg -o dir::cache=/tmp\n"); - return true; } /*}}}*/ diff --git a/cmdline/apt.cc b/cmdline/apt.cc index be2f7663e..3eae22199 100644 --- a/cmdline/apt.cc +++ b/cmdline/apt.cc @@ -39,22 +39,12 @@ bool ShowHelp(CommandLine &, aptDispatchWithHelp const * Cmds) /*{{{*/ { - ioprintf(std::cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH); - - // FIXME: generate from CommandLine std::cout << _("Usage: apt [options] command\n" "\n" "CLI for apt.\n") - << std::endl - << _("Commands:") << std::endl; - for (; Cmds->Handler != nullptr; ++Cmds) - { - if (Cmds->Help == nullptr) - continue; - std::cout << " " << Cmds->Match << " - " << Cmds->Help << std::endl; - } - + << std::endl; + ShowHelpListCommands(Cmds); return true; } /*}}}*/ diff --git a/ftparchive/apt-ftparchive.cc b/ftparchive/apt-ftparchive.cc index 0abb3e2dd..99d5627f0 100644 --- a/ftparchive/apt-ftparchive.cc +++ b/ftparchive/apt-ftparchive.cc @@ -606,11 +606,7 @@ static void LoadBinDir(vector<PackageMap> &PkgList,Configuration &Setup) bool ShowHelp(CommandLine &, aptDispatchWithHelp const *) /*{{{*/ { - ioprintf(cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH); - if (_config->FindB("version") == true) - return true; - - cout << + std::cout << _("Usage: apt-ftparchive [options] command\n" "Commands: packages binarypath [overridefile [pathprefix]]\n" " sources srcpath [overridefile [pathprefix]]\n" @@ -649,7 +645,6 @@ bool ShowHelp(CommandLine &, aptDispatchWithHelp const *) /*{{{*/ " --contents Control contents file generation\n" " -c=? Read this configuration file\n" " -o=? Set an arbitrary configuration option") << endl; - return true; } /*}}}*/ |