From e7e10e47476606e3b2274cf66b1e8ea74b236757 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 24 Oct 2015 22:43:37 +0200 Subject: deduplicate main methods All mains pretty much do the same thing, so lets try a little harder to move the common parts into -private to have the real differences more visible. Git-Dch: Ignore --- cmdline/apt-extracttemplates.cc | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) (limited to 'cmdline/apt-extracttemplates.cc') diff --git a/cmdline/apt-extracttemplates.cc b/cmdline/apt-extracttemplates.cc index cd52cfe33..e28b42870 100644 --- a/cmdline/apt-extracttemplates.cc +++ b/cmdline/apt-extracttemplates.cc @@ -34,6 +34,7 @@ #include #include +#include #include #include @@ -344,34 +345,15 @@ static bool Go(CommandLine &CmdL) /*}}}*/ int main(int argc, const char **argv) /*{{{*/ { - CommandLine::Args Args[] = { - {'h',"help","help",0}, - {'v',"version","version",0}, - {'t',"tempdir","APT::ExtractTemplates::TempDir",CommandLine::HasArg}, - {'c',"config-file",0,CommandLine::ConfigFile}, - {'o',"option",0,CommandLine::ArbItem}, - {0,0,0,0}}; - - // Set up gettext support - setlocale(LC_ALL,""); - textdomain(PACKAGE); + InitLocale(); // Parse the command line and initialize the package library CommandLine::DispatchWithHelp Cmds[] = {{nullptr, nullptr, nullptr}}; CommandLine CmdL; - ParseCommandLine(CmdL, Cmds, Args, &_config, &_system, argc, argv, ShowHelp); + ParseCommandLine(CmdL, Cmds, "apt-extracttemplates", &_config, &_system, argc, argv, ShowHelp); Go(CmdL); - // Print any errors or warnings found during operation - if (_error->empty() == false) - { - // This goes to stderr.. - bool Errors = _error->PendingError(); - _error->DumpErrors(); - return Errors == true?100:0; - } - - return 0; + return DispatchCommandLine(CmdL, nullptr); } /*}}}*/ -- cgit v1.2.3