/*}}}*/
#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);
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});
(Sys != NULL && pkgInitSystem(*_config, *Sys) == false))
{
if (_config->FindB("version") == true)
- ShowHelp(CmdL, CmdsWithHelp.data());
+ ShowCommonHelp(Binary, CmdL, CmdsWithHelp.data());
_error->DumpErrors();
exit(100);
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;
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);
/*}}}*/
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"
/*}}}*/
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"
/*}}}*/
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"
/*}}}*/
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"
/*}}}*/
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;
"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"
/*}}}*/
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;
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"
/*}}}*/
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"
/*}}}*/
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"
" -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;
}
/*}}}*/
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;
}
/*}}}*/
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"
" --contents Control contents file generation\n"
" -c=? Read this configuration file\n"
" -o=? Set an arbitrary configuration option") << endl;
-
return true;
}
/*}}}*/