]> git.saurik.com Git - apt.git/blobdiff - cmdline/apt-mark.cc
deal with --version more centrally
[apt.git] / cmdline / apt-mark.cc
index 0a5bb164afe1b5603bd81381f31885df2adbcd85..b06fcc0ccbeef13b0307ea6b93271120f719fb56 100644 (file)
@@ -280,26 +280,15 @@ static bool ShowSelection(CommandLine &CmdL)                              /*{{{*/
    return true;
 }
                                                                        /*}}}*/
-// ShowHelp - Show a help screen                                       /*{{{*/
-static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds)
+bool ShowHelp(CommandLine &, aptDispatchWithHelp const * Cmds)         /*{{{*/
 {
-   ioprintf(std::cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH);
-
    std::cout <<
     _("Usage: apt-mark [options] {auto|manual} pkg1 [pkg2 ...]\n"
       "\n"
       "apt-mark is a simple command line interface for marking packages\n"
       "as manually or automatically installed. It can also list marks.\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::endl;
+   ShowHelpListCommands(Cmds);
    std::cout << std::endl
    << _("Options:\n"
       "  -h  This help text.\n"
@@ -314,11 +303,9 @@ static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds)
    return true;
 }
                                                                        /*}}}*/
-int main(int argc,const char *argv[])                                  /*{{{*/
+std::vector<aptDispatchWithHelp> GetCommands()                         /*{{{*/
 {
-   InitLocale();
-
-   CommandLine::DispatchWithHelp Cmds[] = {
+   return {
       {"auto",&DoAuto, _("Mark the given packages as automatically installed")},
       {"manual",&DoAuto, _("Mark the given packages as manually installed")},
       {"hold",&DoSelection, _("Mark a package as held back")},
@@ -339,9 +326,14 @@ int main(int argc,const char *argv[])                                      /*{{{*/
       {"unmarkauto", &DoMarkAuto, nullptr},
       {nullptr, nullptr, nullptr}
    };
+}
+                                                                       /*}}}*/
+int main(int argc,const char *argv[])                                  /*{{{*/
+{
+   InitLocale();
 
    CommandLine CmdL;
-   ParseCommandLine(CmdL, Cmds, "apt-mark", &_config, &_system, argc, argv, ShowHelp);
+   auto const Cmds = ParseCommandLine(CmdL, APT_CMD::APT_MARK, &_config, &_system, argc, argv);
 
    InitOutput();