summaryrefslogtreecommitdiff
path: root/ftparchive/apt-ftparchive.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 /ftparchive/apt-ftparchive.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 'ftparchive/apt-ftparchive.cc')
-rw-r--r--ftparchive/apt-ftparchive.cc36
1 files changed, 5 insertions, 31 deletions
diff --git a/ftparchive/apt-ftparchive.cc b/ftparchive/apt-ftparchive.cc
index 857f0aff5..ca03080ca 100644
--- a/ftparchive/apt-ftparchive.cc
+++ b/ftparchive/apt-ftparchive.cc
@@ -21,6 +21,7 @@
#include <apt-private/private-cmndline.h>
#include <apt-private/private-output.h>
+#include <apt-private/private-main.h>
#include <algorithm>
#include <climits>
@@ -1026,25 +1027,7 @@ static bool Clean(CommandLine &CmdL)
int main(int argc, const char *argv[])
{
- setlocale(LC_ALL, "");
- CommandLine::Args Args[] = {
- {'h',"help","help",0},
- {0,"md5","APT::FTPArchive::MD5",0},
- {0,"sha1","APT::FTPArchive::SHA1",0},
- {0,"sha256","APT::FTPArchive::SHA256",0},
- {0,"sha512","APT::FTPArchive::SHA512",0},
- {'v',"version","version",0},
- {'d',"db","APT::FTPArchive::DB",CommandLine::HasArg},
- {'s',"source-override","APT::FTPArchive::SourceOverride",CommandLine::HasArg},
- {'q',"quiet","quiet",CommandLine::IntLevel},
- {'q',"silent","quiet",CommandLine::IntLevel},
- {0,"delink","APT::FTPArchive::DeLinkAct",0},
- {0,"readonly","APT::FTPArchive::ReadOnlyDB",0},
- {0,"contents","APT::FTPArchive::Contents",0},
- {'a',"arch","APT::FTPArchive::Architecture",CommandLine::HasArg},
- {'c',"config-file",0,CommandLine::ConfigFile},
- {'o',"option",0,CommandLine::ArbItem},
- {0,0,0,0}};
+ InitLocale();
CommandLine::DispatchWithHelp Cmds[] = {
{"packages",&SimpleGenPackages, nullptr},
@@ -1057,21 +1040,12 @@ int main(int argc, const char *argv[])
};
// Parse the command line and initialize the package library
- CommandLine CmdL(Args,_config);
- ParseCommandLine(CmdL, Cmds, Args, &_config, NULL, argc, argv, ShowHelp);
+ CommandLine CmdL;
+ ParseCommandLine(CmdL, Cmds, "apt-ftparchive", &_config, NULL, argc, argv, ShowHelp);
_config->CndSet("quiet",0);
Quiet = _config->FindI("quiet",0);
InitOutput(clog.rdbuf());
- // Match the operation
- CmdL.DispatchArg(Cmds);
-
- if (_error->empty() == false)
- {
- bool Errors = _error->PendingError();
- _error->DumpErrors();
- return Errors == true?100:0;
- }
- return 0;
+ return DispatchCommandLine(CmdL, Cmds);
}