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-helper.cc | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'cmdline/apt-helper.cc') diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc index dc4efb32b..3df858813 100644 --- a/cmdline/apt-helper.cc +++ b/cmdline/apt-helper.cc @@ -106,7 +106,7 @@ static bool DoSrvLookup(CommandLine &CmdL) return true; } -static bool ShowHelp(CommandLine &) +static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds) { ioprintf(std::cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH); @@ -117,28 +117,34 @@ static bool ShowHelp(CommandLine &) _("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" - "\n" - "Commands:\n" - " download-file - download the given uri to the target-path\n" - " srv-lookup - lookup a SRV record (e.g. _http._tcp.ftp.debian.org)\n" - " auto-detect-proxy - detect proxy using apt.conf\n" - "\n" - " This APT helper has Super Meep Powers.\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::cout << std::endl << + _("This APT helper has Super Meep Powers.") << std::endl; return true; } int main(int argc,const char *argv[]) /*{{{*/ { - CommandLine::Dispatch Cmds[] = {{"help",&ShowHelp}, - {"download-file", &DoDownloadFile}, - {"srv-lookup", &DoSrvLookup}, - {"auto-detect-proxy", &DoAutoDetectProxy}, - {0,0}}; + CommandLine::DispatchWithHelp Cmds[] = { + {"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} + }; std::vector Args = getCommandArgs( - "apt-download", CommandLine::GetCommand(Cmds, argc, argv)); + "apt-helper", CommandLine::GetCommand(Cmds, argc, argv)); // Set up gettext support setlocale(LC_ALL,""); -- cgit v1.2.3