X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/7414af7fa88164209eec9c585b8d175c1618ecbc..ae2a6be8a2155c136f9535abfbcc750c8c395cd2:/cmdline/apt-sortpkgs.cc diff --git a/cmdline/apt-sortpkgs.cc b/cmdline/apt-sortpkgs.cc index cde3069bd..b80bbedd6 100644 --- a/cmdline/apt-sortpkgs.cc +++ b/cmdline/apt-sortpkgs.cc @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -131,62 +132,34 @@ static bool DoIt(string InFile) return true; } /*}}}*/ -// ShowHelp - Show the help text /*{{{*/ -// --------------------------------------------------------------------- -/* */ -static bool ShowHelp(CommandLine &) +static bool ShowHelp(CommandLine &) /*{{{*/ { - ioprintf(std::cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH); - if (_config->FindB("version") == true) - return true; - - cout << + std::cout << _("Usage: apt-sortpkgs [options] file1 [file2 ...]\n" "\n" - "apt-sortpkgs is a simple tool to sort package files. The -s option is used\n" - "to indicate what kind of file it is.\n" - "\n" - "Options:\n" - " -h This help text\n" - " -s Use source file sorting\n" - " -c=? Read this configuration file\n" - " -o=? Set an arbitrary configuration option, eg -o dir::cache=/tmp\n"); - + "apt-sortpkgs is a simple tool to sort package information files.\n" + "By default it sorts by binary package information, but the -s option\n" + "can be used to switch to source package ordering instead.\n"); return true; } /*}}}*/ +static std::vector GetCommands() /*{{{*/ +{ + return { + {nullptr, nullptr, nullptr} + }; +} + /*}}}*/ 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); - - // Parse the command line and initialize the package library - CommandLine::Dispatch Cmds[] = {{NULL, NULL}}; CommandLine CmdL; - ParseCommandLine(CmdL, Cmds, Args, &_config, &_system, argc, argv, ShowHelp); + ParseCommandLine(CmdL, APT_CMD::APT_SORTPKG, &_config, &_system, argc, argv, &ShowHelp, &GetCommands); // 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, {}); } /*}}}*/