]> git.saurik.com Git - apt.git/blobdiff - cmdline/apt-cache.cc
print all messages if the application is in an interactive run
[apt.git] / cmdline / apt-cache.cc
index de4288c5a8392e0f4fd8e8be79c9cc5698533493..a4ec63eeda0a65544410fdfadf9004819fc610cd 100644 (file)
@@ -29,7 +29,8 @@
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/algorithms.h>
 #include <apt-pkg/sptr.h>
-#include <apt-pkg/cacheset.h>
+
+#include "cacheset.h"
 
 #include <config.h>
 #include <apti18n.h>
@@ -787,38 +788,24 @@ bool XVcg(CommandLine &CmdL)
            ShapeMap[Pkg->ID] = 3;
       }
    }
-   
+
    // Load the list of packages from the command line into the show list
-   for (const char **I = CmdL.FileList + 1; *I != 0; I++)
+   std::list<APT::PackageSet::Modifier> mods;
+   mods.push_back(APT::PackageSet::Modifier(0, ",", APT::PackageSet::Modifier::POSTFIX));
+   mods.push_back(APT::PackageSet::Modifier(1, "^", APT::PackageSet::Modifier::POSTFIX));
+   std::map<unsigned short, APT::PackageSet> pkgsets =
+               APT::PackageSet::GroupedFromCommandLine(CacheFile, CmdL.FileList + 1, mods, 0);
+
+   for (APT::PackageSet::const_iterator Pkg = pkgsets[0].begin();
+       Pkg != pkgsets[0].end(); ++Pkg)
+      Show[Pkg->ID] = ToShow;
+   for (APT::PackageSet::const_iterator Pkg = pkgsets[1].begin();
+       Pkg != pkgsets[1].end(); ++Pkg)
    {
-      // Process per-package flags
-      string P = *I;
-      bool Force = false;
-      if (P.length() > 3)
-      {
-        if (P.end()[-1] == '^')
-        {
-           Force = true;
-           P.erase(P.end()-1);
-        }
-        
-        if (P.end()[-1] == ',')
-           P.erase(P.end()-1);
-      }
-      
-      // Locate the package
-      pkgCache::PkgIterator Pkg = Cache->FindPkg(P);
-      if (Pkg.end() == true)
-      {
-        _error->Warning(_("Unable to locate package %s"),*I);
-        continue;
-      }
       Show[Pkg->ID] = ToShow;
-      
-      if (Force == true)
-        Flags[Pkg->ID] |= ForceNR;
+      Flags[Pkg->ID] |= ForceNR;
    }
-   
+
    // Little header
    cout << "graph: { title: \"packages\"" << endl <<
      "xmax: 700 ymax: 700 x: 30 y: 30" << endl <<
@@ -1015,38 +1002,24 @@ bool Dotty(CommandLine &CmdL)
            ShapeMap[Pkg->ID] = 3;
       }
    }
-   
+
    // Load the list of packages from the command line into the show list
-   for (const char **I = CmdL.FileList + 1; *I != 0; I++)
+   std::list<APT::PackageSet::Modifier> mods;
+   mods.push_back(APT::PackageSet::Modifier(0, ",", APT::PackageSet::Modifier::POSTFIX));
+   mods.push_back(APT::PackageSet::Modifier(1, "^", APT::PackageSet::Modifier::POSTFIX));
+   std::map<unsigned short, APT::PackageSet> pkgsets =
+               APT::PackageSet::GroupedFromCommandLine(CacheFile, CmdL.FileList + 1, mods, 0);
+
+   for (APT::PackageSet::const_iterator Pkg = pkgsets[0].begin();
+       Pkg != pkgsets[0].end(); ++Pkg)
+      Show[Pkg->ID] = ToShow;
+   for (APT::PackageSet::const_iterator Pkg = pkgsets[1].begin();
+       Pkg != pkgsets[1].end(); ++Pkg)
    {
-      // Process per-package flags
-      string P = *I;
-      bool Force = false;
-      if (P.length() > 3)
-      {
-        if (P.end()[-1] == '^')
-        {
-           Force = true;
-           P.erase(P.end()-1);
-        }
-        
-        if (P.end()[-1] == ',')
-           P.erase(P.end()-1);
-      }
-      
-      // Locate the package
-      pkgCache::PkgIterator Pkg = Cache->FindPkg(P);
-      if (Pkg.end() == true)
-      {
-        _error->Warning(_("Unable to locate package %s"),*I);
-        continue;
-      }
       Show[Pkg->ID] = ToShow;
-      
-      if (Force == true)
-        Flags[Pkg->ID] |= ForceNR;
+      Flags[Pkg->ID] |= ForceNR;
    }
-   
+
    // Little header
    printf("digraph packages {\n");
    printf("concentrate=true;\n");
@@ -1903,13 +1876,11 @@ int main(int argc,const char *argv[])                                   /*{{{*/
       CmdL.DispatchArg(CmdsB);
 
    // Print any errors or warnings found during parsing
-   if (_error->empty() == false)
-   {
-      bool Errors = _error->PendingError();
+   bool const Errors = _error->PendingError();
+   if (_config->FindI("quiet",0) > 0)
       _error->DumpErrors();
-      return Errors == true?100:0;
-   }
-          
-   return 0;
+   else
+      _error->DumpErrors(GlobalError::DEBUG);
+   return Errors == true ? 100 : 0;
 }
                                                                        /*}}}*/