emerge: support [ y | n ] for --ask
authorZac Medico <zmedico@gentoo.org>
Thu, 24 Mar 2011 18:15:47 +0000 (11:15 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 24 Mar 2011 18:15:47 +0000 (11:15 -0700)
This allows --ask to be enabled via EMERGE_DEFAULT_OPTS, and then
temporarily disabled via the command-line. This may be useful for
programs that call emerge non-interactively, as in bug #360233.

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

index 0e3eb13125e7c6e3b03571051e35e98ec1660c24..2693b6753de5da5793904f31ef5c40cf3a3b5ab8 100644 (file)
@@ -270,7 +270,7 @@ configuration, this would result in an effective
 When displaying USE and other flag output, combines the enabled and
 disabled lists into one list and sorts the whole list alphabetically.
 .TP
-.BR "\-\-ask " (\fB\-a\fR)
+.BR "\-\-ask [ y | n ] (\-a short option)"
 Before performing the action, display what will take place (server info for
 \fB\-\-sync\fR, \fB\-\-pretend\fR output for merge, and so forth), then ask
 whether to proceed with the action or abort.  Using \fB\-\-ask\fR is more
index 020bc42064e791de292634457c7604a84a755b4a..a120f54d39919cfced9748af500edbce4bd81998 100644 (file)
@@ -280,7 +280,9 @@ def help(myopts, havecolor=1):
                print("              With this option, output such as USE=\"dar -bar -foo\" will instead")
                print("              be displayed as USE=\"-bar dar -foo\"")
                print()
-               print("       "+green("--ask")+" ("+green("-a")+" short option)")
+               print("       " + green("--ask") + \
+                       " [ %s | %s ] (%s short option)" % \
+                       (turquoise("y"), turquoise("n"), green("-a")))
                desc = "Before performing the action, display what will take place (server info for " + \
                        "--sync, --pretend output for merge, and so forth), then ask " + \
                        "whether to proceed with the action or abort.  Using --ask is more " + \
index 1a63bc7dbbb28cde583827d10fe7c337035481e5..d4b14fcc43046160bf70403b0a8710678ccf4cab 100644 (file)
@@ -50,7 +50,7 @@ if sys.hexversion >= 0x3000000:
        long = int
 
 options=[
-"--ask",          "--alphabetical",
+"--alphabetical",
 "--ask-enter-invalid",
 "--buildpkgonly",
 "--changed-use",
@@ -77,7 +77,6 @@ options=[
 
 shortmapping={
 "1":"--oneshot",
-"a":"--ask",
 "B":"--buildpkgonly",
 "c":"--depclean",
 "C":"--unmerge",
@@ -422,6 +421,7 @@ def insert_optional_args(args):
        new_args = []
 
        default_arg_opts = {
+               '--ask'                  : y_or_n,
                '--autounmask'           : y_or_n,
                '--buildpkg'             : y_or_n,
                '--complete-graph'       : y_or_n,
@@ -456,6 +456,7 @@ def insert_optional_args(args):
        # Don't make things like "-kn" expand to "-k n"
        # since existence of -n makes it too ambiguous.
        short_arg_opts_n = {
+               'a' : y_or_n,
                'b' : y_or_n,
                'g' : y_or_n,
                'G' : y_or_n,
@@ -560,6 +561,13 @@ def parse_opts(tmpcmdline, silent=False):
        true_y = ("True", "y")
        argument_options = {
 
+               "--ask": {
+                       "shortopt" : "-a",
+                       "help"    : "prompt before performing any actions",
+                       "type"    : "choice",
+                       "choices" : true_y_or_n
+               },
+
                "--autounmask": {
                        "help"    : "automatically unmask packages",
                        "type"    : "choice",
@@ -807,6 +815,11 @@ def parse_opts(tmpcmdline, silent=False):
 
        myoptions, myargs = parser.parse_args(args=tmpcmdline)
 
+       if myoptions.ask in true_y:
+               myoptions.ask = True
+       else:
+               myoptions.ask = None
+
        if myoptions.autounmask in true_y:
                myoptions.autounmask = True