summaryrefslogtreecommitdiff
path: root/cmdline/apt-sortpkgs.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-10-24 22:43:37 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2015-11-04 18:04:03 +0100
commite7e10e47476606e3b2274cf66b1e8ea74b236757 (patch)
tree3daed3cc14405879034c562993a7b5399992f2e3 /cmdline/apt-sortpkgs.cc
parentcbbee23e7768750ca1c8b49bdfbf8a650131bbb6 (diff)
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
Diffstat (limited to 'cmdline/apt-sortpkgs.cc')
-rw-r--r--cmdline/apt-sortpkgs.cc27
1 files changed, 5 insertions, 22 deletions
diff --git a/cmdline/apt-sortpkgs.cc b/cmdline/apt-sortpkgs.cc
index e3d520a96..93aa5a76b 100644
--- a/cmdline/apt-sortpkgs.cc
+++ b/cmdline/apt-sortpkgs.cc
@@ -24,6 +24,7 @@
#include <apt-pkg/pkgsystem.h>
#include <apt-private/private-cmndline.h>
+#include <apt-private/private-main.h>
#include <vector>
#include <algorithm>
@@ -157,36 +158,18 @@ static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const *)
/*}}}*/
int main(int argc,const char *argv[]) /*{{{*/
{
- CommandLine::Args Args[] = {
- {'h',"help","help",0},
- {'v',"version","version",0},
- {'s',"source","APT::SortPkgs::Source",0},
- {'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-sortpkgs", &_config, &_system, argc, argv, ShowHelp);
// Match the operation
for (unsigned int I = 0; I != CmdL.FileSize(); I++)
if (DoIt(CmdL.FileList[I]) == false)
break;
-
- // Print any errors or warnings found during parsing
- if (_error->empty() == false)
- {
- bool Errors = _error->PendingError();
- _error->DumpErrors();
- return Errors == true?100:0;
- }
-
- return 0;
+
+ return DispatchCommandLine(CmdL, nullptr);
}
/*}}}*/