diff options
author | David Kalnischkies <david@kalnischkies.de> | 2015-10-25 23:45:09 +0100 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2015-11-04 18:04:04 +0100 |
commit | 011188e3920f21e6883c2dab956b3d4fb4e8cbfa (patch) | |
tree | 9649094789cf2369d82758e24995feb2b0bed59c /cmdline/apt-helper.cc | |
parent | 2b0660b537581e9e65180e4cf1a94d763fd66847 (diff) |
generate commands array after config is loaded
This ensures that location strings loaded from a location specified via
configuration (Dir::Locale) effect the help messages for commands.
Git-Dch: Ignore
Diffstat (limited to 'cmdline/apt-helper.cc')
-rw-r--r-- | cmdline/apt-helper.cc | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc index 186fded17..aef10828d 100644 --- a/cmdline/apt-helper.cc +++ b/cmdline/apt-helper.cc @@ -32,7 +32,7 @@ #include <apti18n.h> /*}}}*/ -static bool DoAutoDetectProxy(CommandLine &CmdL) +static bool DoAutoDetectProxy(CommandLine &CmdL) /*{{{*/ { if (CmdL.FileSize() != 2) return _error->Error(_("Need one URL as argument")); @@ -44,8 +44,8 @@ static bool DoAutoDetectProxy(CommandLine &CmdL) return true; } - -static bool DoDownloadFile(CommandLine &CmdL) + /*}}}*/ +static bool DoDownloadFile(CommandLine &CmdL) /*{{{*/ { if (CmdL.FileSize() <= 2) return _error->Error(_("Must specify at least one pair url/filename")); @@ -77,8 +77,8 @@ static bool DoDownloadFile(CommandLine &CmdL) return true; } - -static bool DoSrvLookup(CommandLine &CmdL) + /*}}}*/ +static bool DoSrvLookup(CommandLine &CmdL) /*{{{*/ { if (CmdL.FileSize() <= 1) return _error->Error("Must specify at least one SRV record"); @@ -104,8 +104,8 @@ static bool DoSrvLookup(CommandLine &CmdL) } return true; } - -static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds) + /*}}}*/ +bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds)/*{{{*/ { ioprintf(std::cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH); @@ -131,22 +131,23 @@ static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds) _("This APT helper has Super Meep Powers.") << std::endl; return true; } - - -int main(int argc,const char *argv[]) /*{{{*/ + /*}}}*/ +std::vector<CommandLine::DispatchWithHelp> GetCommands() /*{{{*/ { - InitLocale(); - - CommandLine::DispatchWithHelp Cmds[] = { + return { {"download-file", &DoDownloadFile, _("download the given uri to the target-path")}, {"srv-lookup", &DoSrvLookup, _("lookup a SRV record (e.g. _http._tcp.ftp.debian.org)")}, {"auto-detect-proxy", &DoAutoDetectProxy, _("detect proxy using apt.conf")}, {nullptr, nullptr, nullptr} }; +} + /*}}}*/ +int main(int argc,const char *argv[]) /*{{{*/ +{ + InitLocale(); - // Parse the command line and initialize the package library CommandLine CmdL; - ParseCommandLine(CmdL, Cmds, "apt-helper", &_config, &_system, argc, argv, ShowHelp); + auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_HELPER, &_config, &_system, argc, argv); InitOutput(); |