]> git.saurik.com Git - apt.git/blobdiff - cmdline/apt-cache.cc
new quiet level -qq for apt to hide progress output
[apt.git] / cmdline / apt-cache.cc
index 24ed9eef3be378075d24532e92bdbdebbe7a0d2a..67e4a852345d29dd8bea875c6300156d371ea497 100644 (file)
@@ -45,6 +45,7 @@
 #include <apt-private/private-cmndline.h>
 #include <apt-private/private-show.h>
 #include <apt-private/private-search.h>
+#include <apt-private/private-main.h>
 
 #include <regex.h>
 #include <stddef.h>
@@ -1522,41 +1523,30 @@ static bool GenCaches(CommandLine &)
 }
                                                                        /*}}}*/
 // ShowHelp - Show a help screen                                       /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-static bool ShowHelp(CommandLine &)
+static bool ShowHelp(CommandLine &, CommandLine::DispatchWithHelp const * Cmds)
 {
    ioprintf(cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH);
 
    if (_config->FindB("version") == true)
      return true;
 
-   cout << 
+   std::cout <<
     _("Usage: apt-cache [options] command\n"
-      "       apt-cache [options] showpkg pkg1 [pkg2 ...]\n"
-      "       apt-cache [options] showsrc pkg1 [pkg2 ...]\n"
+      "       apt-cache [options] show pkg1 [pkg2 ...]\n"
       "\n"
       "apt-cache is a low-level tool used to query information\n"
-      "from APT's binary cache files\n"
-      "\n"
-      "Commands:\n"
-      "   gencaches - Build both the package and source cache\n"
-      "   showpkg - Show some general information for a single package\n"
-      "   showsrc - Show source records\n"
-      "   stats - Show some basic statistics\n"
-      "   dump - Show the entire file in a terse form\n"
-      "   dumpavail - Print an available file to stdout\n"
-      "   unmet - Show unmet dependencies\n"
-      "   search - Search the package list for a regex pattern\n"
-      "   show - Show a readable record for the package\n"
-      "   depends - Show raw dependency information for a package\n"
-      "   rdepends - Show reverse dependency information for a package\n"
-      "   pkgnames - List the names of all packages in the system\n"
-      "   dotty - Generate package graphs for GraphViz\n"
-      "   xvcg - Generate package graphs for xvcg\n"
-      "   policy - Show policy settings\n"
-      "\n"
-      "Options:\n"
+      "from APT's binary cache files\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::cout << std::endl
+    << _("Options:\n"
       "  -h   This help text.\n"
       "  -p=? The package cache.\n"
       "  -s=? The source cache.\n"
@@ -1570,50 +1560,38 @@ static bool ShowHelp(CommandLine &)
                                                                        /*}}}*/
 int main(int argc,const char *argv[])                                  /*{{{*/
 {
-   CommandLine::Dispatch Cmds[] =  {{"help",&ShowHelp},
-                                    {"gencaches",&GenCaches},
-                                    {"showsrc",&ShowSrcPackage},
-                                    {"showpkg",&DumpPackage},
-                                    {"stats",&Stats},
-                                    {"dump",&Dump},
-                                    {"dumpavail",&DumpAvail},
-                                    {"unmet",&UnMet},
-                                    {"search",&DoSearch},
-                                    {"depends",&Depends},
-                                    {"rdepends",&RDepends},
-                                    {"dotty",&Dotty},
-                                    {"xvcg",&XVcg},
-                                    {"show",&ShowPackage},
-                                    {"pkgnames",&ShowPkgNames},
-                                    {"showauto",&ShowAuto},
-                                    {"policy",&Policy},
-                                    {"madison",&Madison},
-                                    {0,0}};
-
-   std::vector<CommandLine::Args> Args = getCommandArgs("apt-cache", CommandLine::GetCommand(Cmds, argc, argv));
-
-   // Set up gettext support
-   setlocale(LC_ALL,"");
-   textdomain(PACKAGE);
+   InitLocale();
+
+   CommandLine::DispatchWithHelp Cmds[] =  {
+      {"gencaches",&GenCaches, nullptr},
+      {"showsrc",&ShowSrcPackage, _("Show source records")},
+      {"showpkg",&DumpPackage, nullptr},
+      {"stats",&Stats, nullptr},
+      {"dump",&Dump, nullptr},
+      {"dumpavail",&DumpAvail, nullptr},
+      {"unmet",&UnMet, nullptr},
+      {"search",&DoSearch, _("Search the package list for a regex pattern")},
+      {"depends",&Depends, _("Show raw dependency information for a package")},
+      {"rdepends",&RDepends, _("Show reverse dependency information for a package")},
+      {"dotty",&Dotty, nullptr},
+      {"xvcg",&XVcg, nullptr},
+      {"show",&ShowPackage, _("Show a readable record for the package")},
+      {"pkgnames",&ShowPkgNames, _("List the names of all packages in the system")},
+      {"showauto",&ShowAuto, nullptr},
+      {"policy",&Policy, _("Show policy settings")},
+      {"madison",&Madison, nullptr},
+      {nullptr, nullptr, nullptr}
+   };
 
    // Parse the command line and initialize the package library
    CommandLine CmdL;
-   ParseCommandLine(CmdL, Cmds, Args.data(), &_config, &_system, argc, argv, ShowHelp);
+   ParseCommandLine(CmdL, Cmds, "apt-cache", &_config, &_system, argc, argv, ShowHelp);
 
    InitOutput();
 
    if (_config->Exists("APT::Cache::Generate") == true)
       _config->Set("pkgCacheFile::Generate", _config->FindB("APT::Cache::Generate", true));
 
-   // Match the operation
-   CmdL.DispatchArg(Cmds);
-
-   // Print any errors or warnings found during parsing
-   bool const Errors = _error->PendingError();
-   if (_config->FindI("quiet",0) > 0)
-      _error->DumpErrors();
-   else
-      _error->DumpErrors(GlobalError::DEBUG);
-   return Errors == true ? 100 : 0;
+   return DispatchCommandLine(CmdL, Cmds);
 }
                                                                        /*}}}*/