]> git.saurik.com Git - apt.git/blobdiff - apt-private/private-cmndline.cc
.travis.yml: Add pinned vivid for gettext and clean up a bit
[apt.git] / apt-private / private-cmndline.cc
index 079f81ee36f4d512ee198384eefa0c6303b73254..1072b9a78b0d113fb8389c3c47d619302cc28603 100644 (file)
@@ -2,12 +2,17 @@
 #include <config.h>
 
 #include <apt-pkg/cmndline.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/pkgsystem.h>
+#include <apt-pkg/init.h>
+#include <apt-pkg/error.h>
 
 #include <apt-private/private-cmndline.h>
 
 #include <vector>
 #include <stdarg.h>
 #include <string.h>
+#include <stdlib.h>
 
 #include <apti18n.h>
                                                                        /*}}}*/
@@ -46,6 +51,7 @@ static bool addArgumentsAPTCache(std::vector<CommandLine::Args> &Args, char cons
       addArg(0, "conflicts", "APT::Cache::ShowConflicts", 0);
       addArg(0, "enhances", "APT::Cache::ShowEnhances", 0);
       addArg(0, "recurse", "APT::Cache::RecurseDepends", 0);
+      addArg(0, "implicit", "APT::Cache::ShowImplicit", 0);
    }
    else if (CmdMatches("search"))
    {
@@ -64,7 +70,11 @@ static bool addArgumentsAPTCache(std::vector<CommandLine::Args> &Args, char cons
    {
       addArg('i', "important", "APT::Cache::Important", 0);
    }
-   else if (CmdMatches("gencaches", "showsrc", "showpkg", "stats", "dump",
+   else if (CmdMatches("showsrc"))
+   {
+      addArg(0,"only-source","APT::Cache::Only-Source",0);
+   }
+   else if (CmdMatches("gencaches", "showpkg", "stats", "dump",
            "dumpavail", "showauto", "policy", "madison"))
       ;
    else
@@ -158,15 +168,20 @@ static bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const
       // once sbuild is fixed, this option can be removed
       addArg('f', "fix-broken", "APT::Get::Fix-Broken", 0);
    }
-   else if (CmdMatches("clean", "autoclean", "check", "download", "changelog") ||
+   else if (CmdMatches("indextargets"))
+   {
+      addArg(0,"format","APT::Get::IndexTargets::Format", CommandLine::HasArg);
+      addArg(0,"release-info","APT::Get::IndexTargets::ReleaseInfo", 0);
+   }
+   else if (CmdMatches("clean", "autoclean", "auto-clean", "check", "download", "changelog") ||
            CmdMatches("markauto", "unmarkauto")) // deprecated commands
       ;
    else if (CmdMatches("moo"))
       addArg(0, "color", "APT::Moo::Color", 0);
 
    if (CmdMatches("install", "remove", "purge", "upgrade", "dist-upgrade",
-           "deselect-upgrade", "autoremove", "clean", "autoclean", "check",
-           "build-dep", "full-upgrade"))
+           "dselect-upgrade", "autoremove", "auto-remove", "clean", "autoclean", "auto-clean", "check",
+           "build-dep", "full-upgrade", "source"))
    {
       addArg('s', "simulate", "APT::Get::Simulate", 0);
       addArg('s', "just-print", "APT::Get::Simulate", 0);
@@ -191,6 +206,9 @@ static bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const
    addArg(0,"ignore-hold","APT::Ignore-Hold",0);
    addArg(0,"upgrade","APT::Get::upgrade",0);
    addArg(0,"only-upgrade","APT::Get::Only-Upgrade",0);
+   addArg(0,"allow-change-held-packages","APT::Get::allow-change-held-packages",CommandLine::Boolean);
+   addArg(0,"allow-remove-essential","APT::Get::allow-remove-essential",CommandLine::Boolean);
+   addArg(0,"allow-downgrades","APT::Get::allow-downgrades",CommandLine::Boolean);
    addArg(0,"force-yes","APT::Get::force-yes",0);
    addArg(0,"print-uris","APT::Get::Print-URIs",0);
    addArg(0,"trivial-only","APT::Get::Trivial-Only",0);
@@ -231,6 +249,7 @@ static bool addArgumentsAPT(std::vector<CommandLine::Args> &Args, char const * c
    if (CmdMatches("list"))
    {
       addArg(0,"installed","APT::Cmd::Installed",0);
+      addArg(0,"upgradeable","APT::Cmd::Upgradable",0);
       addArg(0,"upgradable","APT::Cmd::Upgradable",0);
       addArg(0,"manual-installed","APT::Cmd::Manual-Installed",0);
       addArg('v', "verbose", "APT::Cmd::List-Include-Summary", 0);
@@ -287,3 +306,31 @@ std::vector<CommandLine::Args> getCommandArgs(char const * const Program, char c
                                                                        /*}}}*/
 #undef CmdMatches
 #undef addArg
+void ParseCommandLine(CommandLine &CmdL, CommandLine::Dispatch * const Cmds, CommandLine::Args * const Args,/*{{{*/
+      Configuration * const * const Cnf, pkgSystem ** const Sys, int const argc, const char *argv[], bool(*ShowHelp)(CommandLine &CmdL))
+{
+   CmdL = CommandLine(Args,_config);
+   if ((Cnf != NULL && pkgInitConfig(**Cnf) == false) ||
+       CmdL.Parse(argc,argv) == false ||
+       (Sys != NULL && pkgInitSystem(*_config, *Sys) == false))
+   {
+      if (_config->FindB("version") == true)
+        ShowHelp(CmdL);
+
+      _error->DumpErrors();
+      exit(100);
+   }
+
+   // See if the help should be shown
+   if (_config->FindB("help") == true || _config->FindB("version") == true)
+   {
+      ShowHelp(CmdL);
+      exit(0);
+   }
+   if (Cmds != NULL && CmdL.FileSize() == 0)
+   {
+      ShowHelp(CmdL);
+      exit(1);
+   }
+}
+                                                                       /*}}}*/