More tweaks to the uses command
authorkarltk <karltk@gentoo.org>
Sun, 22 Aug 2004 21:13:20 +0000 (21:13 -0000)
committerkarltk <karltk@gentoo.org>
Sun, 22 Aug 2004 21:13:20 +0000 (21:13 -0000)
svn path=/; revision=117

trunk/src/equery/TODO
trunk/src/equery/equery

index 15e599625ea1963467bfb6ca48c2113802a4ac2d..05738c6c6e8bde9afdd7c61cd5cbb5e431e28c9f 100644 (file)
@@ -1,2 +1,6 @@
+- clean up colours for output!
+ - error, warning, info
+ - package, searchterm, useflag, number, ...
+ - structured output, to allow for XML, piping and tty?
 - list all global useflags
 - list all local useflags
index 46578e0f07d3a0d6f487888974bf20935a52a887..f9c13826488cadfd953226ba890dfd466918be79 100755 (executable)
@@ -271,6 +271,7 @@ class CmdDisplayUSEs(Command):
     """Advanced report of a package's USE flags"""
     def __init__(self):
         self.default_opts = {
+            "installedOnly" : True
             }
     def parseArgs(self, args):
 
@@ -289,6 +290,8 @@ class CmdDisplayUSEs(Command):
             if x in ["-h","--help"]:
                 need_help = 1
                 break
+            elif x in ["-a", "--all"]:
+                opts["installedOnly"] = False
             else:
                 query = x
 
@@ -305,7 +308,8 @@ class CmdDisplayUSEs(Command):
         matches = gentoolkit.find_packages(query, True)
 
         if not matches:
-            print yellow("No matching packages found for \"%s\"" % query)
+            print red("!!! No matching packages found for \"") + white(query) + red("\"")
+            print
             return
 
         useflags = gentoolkit.settings["USE"].split()    
@@ -344,19 +348,15 @@ class CmdDisplayUSEs(Command):
             if Config["verbosityLevel"] >= 5:
                 print "Warning: Could not load USE flag descriptions from " + gentoolkit.settings["PORTDIR"] + "/profiles/use.desc"
 
-        if not Config["piping"]: 
+        if Config["verbosityLevel"] >= 2 and not Config["piping"]: 
             print "[ Colour Code : " + green("set") + " " + red("unset") + " ]"
             print "[ Legend    : Left column  (U) - USE flags from make.conf              ]"
             print "[           : Right column (I) - USE flags packages was installed with ]"
 
-        if filter(gentoolkit.Package.is_installed, matches):
-            only_installed = True
-        else:
-            only_installed = False
-
         # Iterate through matches, printing a report for each package
+        printed_matches = 0
         for p in matches:
-            if not p.is_installed() and only_installed:
+            if not p.is_installed() and opts["installedOnly"]:
                 continue
     
             bestver = p.get_cpv()
@@ -423,9 +423,18 @@ class CmdDisplayUSEs(Command):
                             print ":", desc
                         else:
                             print ": unknown"
+                printed_matches += 1
             else:
                 if not Config["piping"]:
                     print "[ No USE flags found for :", white(p.get_cpv()), "]"
+
+        if Config["verbosityLevel"] >= 2:
+            if printed_matches == 0:
+                s = ""
+                if opts["installedOnly"]:
+                    s = "installed "
+                print red("!!! No " + s + "packages found for \"") + white(query) + "\""
+                
                     
     def shortHelp(self):
         return yellow("<local-opts> ") + turquoise("pkgspec") + " - display USE flags for " + turquoise("pkgspec")
@@ -435,7 +444,8 @@ class CmdDisplayUSEs(Command):
                "Syntax:\n" + \
                "  " + green("uses") + yellow(" <local-opts> ") + turquoise("pkgspec") + \
                "\n" + \
-               yellow("<local-opts>") + " is either of: \n"
+               yellow("<local-opts>") + " is either of: \n" + \
+               "  " + yellow("-a, --all") + "     - include non-installed packages\n"
 
 
 class CmdDisplayDepGraph(Command):