commit:     6b17633d0d74cb8fa0eeb46c8ee4f4f05d0e38b2
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Aug 22 20:43:25 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Aug 22 20:49:55 2023 +0000
URL:        https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=6b17633d

eclean-pkg: add --clean-invalid to help, fix parsing

* Rename --clean-invalids -> --clean-invalid
* Add --clean-invalid to help
* Make it default-off for now to match the option name (rather than
  the help saying --no-clean-invalids).

  (I could go either way on what the actual default should be, but this is more
  conservative for now.)
* Fix typo in option name.
* Make it a package specific arg, not a global one.

Bug: https://bugs.gentoo.org/900224
Fixes: 204b1abca2c0cbbdad188c7fd4b84452c2f630a0
Fixes: a16d0d4fbfb4614832c4b682b41284a9050af29f
Signed-off-by: Sam James <sam <AT> gentoo.org>

 pym/gentoolkit/eclean/cli.py | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/pym/gentoolkit/eclean/cli.py b/pym/gentoolkit/eclean/cli.py
index c8381a0..aa8b20f 100644
--- a/pym/gentoolkit/eclean/cli.py
+++ b/pym/gentoolkit/eclean/cli.py
@@ -261,6 +261,11 @@ def printUsage(_error=None, help=None, 
unresolved_invalids=None):
             + "               - delete packages for which ebuild dependencies 
have changed",
             file=out,
         )
+        print(
+            yellow("     --clean-invalid")
+            + "               - cleanup invalid binpkgs",
+            file=out,
+        )
         print(
             yellow(" -i, --ignore-failure")
             + "             - ignore failure to locate PKGDIR",
@@ -413,8 +418,8 @@ def parseArgs(options={}):
                 options["ignore-failure"] = True
             elif o in ("-u", "--unique-use"):
                 options["unique-use"] = True
-            elif o in ("-N", "--skip-invalids"):
-                options["clean-invalids"] = False
+            elif o in ("-N", "--skip-invalid"):
+                options["clean-invalid"] = False
             else:
                 return_code = False
         # sanity check of --deep only options:
@@ -435,7 +440,7 @@ def parseArgs(options={}):
 
     # here are the different allowed command line options (getopt args)
     getopt_options = {"short": {}, "long": {}}
-    getopt_options["short"]["global"] = "CdDipqe:t:nhVvN"
+    getopt_options["short"]["global"] = "CdDipqe:t:nhVv"
     getopt_options["long"]["global"] = [
         "nocolor",
         "deep",
@@ -450,14 +455,14 @@ def parseArgs(options={}):
         "help",
         "version",
         "verbose",
-        "clean-inavlids",
     ]
     getopt_options["short"]["distfiles"] = "fs:"
     getopt_options["long"]["distfiles"] = ["fetch-restricted", "size-limit="]
-    getopt_options["short"]["packages"] = "i"
+    getopt_options["short"]["packages"] = "iN"
     getopt_options["long"]["packages"] = [
         "ignore-failure",
         "changed-deps",
+        "clean-invalid",
         "unique-use",
     ]
     # set default options, except 'nocolor', which is set in main()
@@ -474,8 +479,8 @@ def parseArgs(options={}):
     options["verbose"] = False
     options["changed-deps"] = False
     options["ignore-failure"] = False
+    options["clean-invalid"] = False
     options["unique-use"] = False
-    options["clean-invalids"] = True
     # if called by a well-named symlink, set the action accordingly:
     action = None
     # temp print line to ensure it is the svn/branch code running, etc..
@@ -621,7 +626,7 @@ def doAction(action, options, exclude={}, output=None):
         output.set_colors("deprecated")
         output.list_pkgs(deprecated)
     if action in ["packages"]:
-        if invalids and options["clean-invalids"]:
+        if invalids and options["clean-invalid"]:
             if type(invalids) == list:
                 printUsage(_error="invalid_paths", 
unresolved_invalids=invalids)
                 sys.exit(1)

Reply via email to