From cbbee23e7768750ca1c8b49bdfbf8a650131bbb6 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 22 Oct 2015 16:28:54 +0200 Subject: split up help messages for simpler reuse That is one huge commit with busy work only: Help messages used to be one big translateable string, which is a pain for translators and hard to reuse for us. This change there 'explodes' this single string into new string for each documented string trying hard to split up the translated messages as well. This actually restores many translations as previously adding a single command made all of the bug message fuzzy. The splitup also highlighted that its easy to forget a line, duplicate one and similar stuff. Git-Dch: Ignore --- cmdline/apt-cache.cc | 80 +++++++++++++++++++++++----------------------------- 1 file changed, 35 insertions(+), 45 deletions(-) (limited to 'cmdline/apt-cache.cc') diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index 24ed9eef3..4b3a74922 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -1522,41 +1522,30 @@ static bool GenCaches(CommandLine &) } /*}}}*/ // ShowHelp - Show a help screen /*{{{*/ -// --------------------------------------------------------------------- -/* */ -static bool ShowHelp(CommandLine &) +static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds) { ioprintf(cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH); if (_config->FindB("version") == true) return true; - cout << + std::cout << _("Usage: apt-cache [options] command\n" - " apt-cache [options] showpkg pkg1 [pkg2 ...]\n" - " apt-cache [options] showsrc pkg1 [pkg2 ...]\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" - "\n" - "Commands:\n" - " gencaches - Build both the package and source cache\n" - " showpkg - Show some general information for a single package\n" - " showsrc - Show source records\n" - " stats - Show some basic statistics\n" - " dump - Show the entire file in a terse form\n" - " dumpavail - Print an available file to stdout\n" - " unmet - Show unmet dependencies\n" - " search - Search the package list for a regex pattern\n" - " show - Show a readable record for the package\n" - " depends - Show raw dependency information for a package\n" - " rdepends - Show reverse dependency information for a package\n" - " pkgnames - List the names of all packages in the system\n" - " dotty - Generate package graphs for GraphViz\n" - " xvcg - Generate package graphs for xvcg\n" - " policy - Show policy settings\n" - "\n" - "Options:\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::cout << std::endl + << _("Options:\n" " -h This help text.\n" " -p=? The package cache.\n" " -s=? The source cache.\n" @@ -1570,25 +1559,26 @@ static bool ShowHelp(CommandLine &) /*}}}*/ int main(int argc,const char *argv[]) /*{{{*/ { - CommandLine::Dispatch Cmds[] = {{"help",&ShowHelp}, - {"gencaches",&GenCaches}, - {"showsrc",&ShowSrcPackage}, - {"showpkg",&DumpPackage}, - {"stats",&Stats}, - {"dump",&Dump}, - {"dumpavail",&DumpAvail}, - {"unmet",&UnMet}, - {"search",&DoSearch}, - {"depends",&Depends}, - {"rdepends",&RDepends}, - {"dotty",&Dotty}, - {"xvcg",&XVcg}, - {"show",&ShowPackage}, - {"pkgnames",&ShowPkgNames}, - {"showauto",&ShowAuto}, - {"policy",&Policy}, - {"madison",&Madison}, - {0,0}}; + CommandLine::DispatchWithHelp Cmds[] = { + {"gencaches",&GenCaches, nullptr}, + {"showsrc",&ShowSrcPackage, _("Show source records")}, + {"showpkg",&DumpPackage, nullptr}, + {"stats",&Stats, nullptr}, + {"dump",&Dump, nullptr}, + {"dumpavail",&DumpAvail, nullptr}, + {"unmet",&UnMet, nullptr}, + {"search",&DoSearch, _("Search the package list for a regex pattern")}, + {"depends",&Depends, _("Show raw dependency information for a package")}, + {"rdepends",&RDepends, _("Show reverse dependency information for a package")}, + {"dotty",&Dotty, nullptr}, + {"xvcg",&XVcg, nullptr}, + {"show",&ShowPackage, _("Show a readable record for the package")}, + {"pkgnames",&ShowPkgNames, _("List the names of all packages in the system")}, + {"showauto",&ShowAuto, nullptr}, + {"policy",&Policy, _("Show policy settings")}, + {"madison",&Madison, nullptr}, + {nullptr, nullptr, nullptr} + }; std::vector Args = getCommandArgs("apt-cache", CommandLine::GetCommand(Cmds, argc, argv)); -- cgit v1.2.3