From 011188e3920f21e6883c2dab956b3d4fb4e8cbfa Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 25 Oct 2015 23:45:09 +0100 Subject: 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 --- ftparchive/apt-ftparchive.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'ftparchive') diff --git a/ftparchive/apt-ftparchive.cc b/ftparchive/apt-ftparchive.cc index ca03080ca..f53958ceb 100644 --- a/ftparchive/apt-ftparchive.cc +++ b/ftparchive/apt-ftparchive.cc @@ -605,9 +605,7 @@ static void LoadBinDir(vector &PkgList,Configuration &Setup) /*}}}*/ // ShowHelp - Show the help text /*{{{*/ -// --------------------------------------------------------------------- -/* */ -static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const *) +bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const *) { ioprintf(cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH); if (_config->FindB("version") == true) @@ -1025,11 +1023,9 @@ static bool Clean(CommandLine &CmdL) } /*}}}*/ -int main(int argc, const char *argv[]) +std::vector GetCommands() /*{{{*/ { - InitLocale(); - - CommandLine::DispatchWithHelp Cmds[] = { + return { {"packages",&SimpleGenPackages, nullptr}, {"contents",&SimpleGenContents, nullptr}, {"sources",&SimpleGenSources, nullptr}, @@ -1038,10 +1034,15 @@ int main(int argc, const char *argv[]) {"clean",&Clean, nullptr}, {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-ftparchive", &_config, NULL, argc, argv, ShowHelp); + auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_FTPARCHIVE, &_config, NULL, argc, argv); _config->CndSet("quiet",0); Quiet = _config->FindI("quiet",0); @@ -1049,3 +1050,4 @@ int main(int argc, const char *argv[]) return DispatchCommandLine(CmdL, Cmds); } + /*}}}*/ -- cgit v1.2.3