commit:     fe530a21c5a873382f15ff9407e8af9e10270252
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Fri Jul 18 02:23:54 2014 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Fri Jul 18 02:23:54 2014 +0000
URL:        
http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=fe530a21

roverlay/argparser: add add-policy args to main script

not adding all PKG_* actions, just revbump-on-collision, force-replace and
replace-only, plus {package,ebuild}-list (read extended statements from files).

A typical usage scenario would be:
   roverlay --replace "pkg0" --revbump "cat/p2" --replace-only "*"
or
   roverlay --ebuild-list /tmp/my_list --replace-only "*"

---
 roverlay/argparser.py | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/roverlay/argparser.py b/roverlay/argparser.py
index 706cf5f..c323ce3 100644
--- a/roverlay/argparser.py
+++ b/roverlay/argparser.py
@@ -12,6 +12,9 @@ import roverlay.core
 import roverlay.argutil
 import roverlay.util.objects
 
+import roverlay.overlay.abccontrol
+from roverlay.overlay.abccontrol import AdditionControlResult
+
 # lazy import
 from roverlay.argutil import \
    LOG_LEVELS, \
@@ -449,8 +452,65 @@ class RoverlayArgumentParserBase ( 
roverlay.argutil.ArgumentParserProxy ):
          default=argparse.SUPPRESS, flags=self.ARG_WITH_DEFAULT,
          help="choose how Manifest files are created (ebuild(1) or internal)",
       )
+
+      self._setup_addition_control ( arg )
    # --- end of setup_overlay_creation (...) ---
 
+   def _setup_addition_control ( self, add_arg ):
+##      # all:
+##      for name in AdditionControlResult.PKG_DESCRIPTION_REVMAP, ~X~:
+
+      for variant in [ "package", ]:
+         for name, long_name in [
+            ( "revbump",         "revbump-on-collision"  ),
+            ( "replace",         "force-replace"         ),
+            ( "replace-only",    "replace-only"          ),
+         ]:
+            arg_opt = (
+               "--{variant}-{name}".format ( variant=variant, name=name )
+            )
+
+            dest_name = "{variant}_{aname}".format (
+               variant = variant,
+               aname   = long_name.replace ( "-", "_" )
+            )
+
+
+            add_arg (
+               arg_opt,
+               dest = "cmdline_" + dest_name,
+               metavar = "<{variant}>".format ( variant=variant ),
+               default = [],
+               action  = 'append',
+               help    = (
+                  'set add-policy for <{variant}> to {lname!r}'.format (
+                     variant = variant,
+                     lname   = long_name,
+                  )
+               )
+            )
+      # -- end for
+
+      for variant in [ "package", "ebuild" ]:
+         arg_opt   = "--{variant}-list".format ( variant=variant )
+         dest_name = "file_{variant}_extended".format ( variant=variant )
+
+         add_arg (
+            arg_opt,
+            dest     = dest_name,
+            default  = None,
+            flags    = self.ARG_WITH_DEFAULT|self.ARG_META_FILE,
+            type     = is_fs_file_or_void,
+            help     = (
+               "file that lists {variant} add-policy statements".format (
+                  variant=variant
+               )
+            )
+         )
+      # -- end for
+
+   # --- end of _setup_addition_control (...) ---
+
    def setup_remote_minimal ( self ):
       arg = self.add_argument_group ( "remote", title="sync options" )
 

Reply via email to