Add a new --list-sets action, as requested by jmbsvicetto. v2.2_rc9
authorZac Medico <zmedico@gentoo.org>
Sun, 21 Sep 2008 16:53:31 +0000 (16:53 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 21 Sep 2008 16:53:31 +0000 (16:53 -0000)
svn path=/main/trunk/; revision=11531

man/emerge.1
pym/_emerge/__init__.py
pym/_emerge/help.py

index e4e0533b4226b46aad6d3d1b47b53b42ca78cf10..a14cc615c495fe113133f2ad0c3ca5f2f100e37e 100644 (file)
@@ -67,7 +67,8 @@ on the current configuration. The default set configuration is located
 in \fB/usr/share/portage/config/sets.conf\fR. Note that a \fIset\fR
 is generally used in conjunction with \fB\-\-update\fR. When used as 
 arguments to \fBemerge\fR sets have to be prefixed with \fB@\fR to be
-recognized.
+recognized. Use the \fB\-\-list\-sets\fR action to display a list of
+available package sets.
 .TP
 .BR atom
 An \fIatom\fR describes bounds on a package that you wish to install.  
@@ -142,6 +143,9 @@ developers when fixing the reported problem.  \fBPlease include this
 information when submitting a bug report.\fR  Expanded output can be obtained 
 with the \fI\-\-verbose\fR option.
 .TP
+.BR \-\-list\-sets
+Displays a list of available package sets.
+.TP
 .BR \-\-metadata
 Transfers metadata cache from ${PORTDIR}/metadata/cache/ to
 /var/cache/edb/dep/ as is normally done on the
index 6cfe7eb663a70355e21ace16a187c6021438cea1..b0d6755941f73bbef582f1b4a78a48cf6abb505e 100644 (file)
@@ -197,12 +197,12 @@ def userquery(prompt, responses=None, colours=None):
                print "Interrupted."
                sys.exit(1)
 
-actions=[
+actions = frozenset([
 "clean", "config", "depclean",
-"info", "metadata",
+"info", "list-sets", "metadata",
 "prune", "regen",  "search",
 "sync",  "unmerge",
-]
+])
 options=[
 "--ask",          "--alphabetical",
 "--buildpkg",     "--buildpkgonly",
@@ -13518,10 +13518,15 @@ def emerge_main():
                        print colorize("BAD", "\n*** emerging by path is broken and may not always work!!!\n")
                        break
 
+       root_config = trees[settings["ROOT"]]["root_config"]
+       if myaction == "list-sets":
+               sys.stdout.write("".join("%s\n" % s for s in sorted(root_config.sets)))
+               sys.stdout.flush()
+               return os.EX_OK
+
        # only expand sets for actions taking package arguments
        oldargs = myfiles[:]
        if myaction in ("clean", "config", "depclean", "info", "prune", "unmerge", None):
-               root_config = trees[settings["ROOT"]]["root_config"]
                setconfig = root_config.setconfig
                # display errors that occured while loading the SetConfig instance
                for e in setconfig.errors:
@@ -13763,8 +13768,6 @@ def emerge_main():
                                "not support '--pretend'.\n") % myaction)
                        return 1
 
-       root_config = trees[settings["ROOT"]]["root_config"]
-
        if "sync" == myaction:
                return action_sync(settings, trees, mtimedb, myopts, myaction)
        elif "metadata" == myaction:
index e0b93480ccd2983ae6649bebccbbfa69dcebd0c4..5c7b0d6e6f888a5e1c3ddf4be528a694f9e06f62 100644 (file)
@@ -20,7 +20,7 @@ def shorthelp():
        print "          [ "+green("--jobs") + " " + turquoise("JOBS")+" ] [ "+green("--keep-going")+" ] [ " + green("--load-average")+" " + turquoise("LOAD") + "            ]"
        print "          [ "+green("--newuse")+"    ] [ "+green("--noconfmem")+"  ] [ "+green("--nospinner")+"  ] [ "+green("--oneshot")+"     ]"
        print "          [ "+green("--reinstall ")+turquoise("changed-use")+"      ] [ " + green("--with-bdeps")+" < " + turquoise("y") + " | "+ turquoise("n")+" >         ]"
-       print bold("Actions:")+"  [ "+green("--clean")+" | "+green("--depclean")+" | "+green("--prune")+" | "+green("--regen")+" | "+green("--search")+" | "+green("--unmerge")+" ]"
+       print bold("Actions:")+"  [ "+green("--depclean")+" | "+green("--list-sets")+" | "+green("--search")+" | "+green("--sync")+" | "+green("--version")+"        ]"
 
 def help(myaction,myopts,havecolor=1):
        # TODO: Implement a wrap() that accounts for console color escape codes.
@@ -112,6 +112,12 @@ def help(myaction,myopts,havecolor=1):
                print "              make.{conf,globals,defaults} and the environment show up if"
                print "              run with the '--verbose' flag."
                print
+               print "       " + green("--list-sets")
+               paragraph = "Displays a list of available package sets."
+
+               for line in wrap(paragraph, desc_width):
+                       print desc_indent + line
+               print
                print "       "+green("--metadata")
                print "              Transfers metadata cache from ${PORTDIR}/metadata/cache/ to"
                print "              /var/cache/edb/dep/ as is normally done on the tail end of an"