]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
samba-tool: --version shortcircuits option evaluation
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 15 Jan 2025 02:32:18 +0000 (15:32 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Sat, 8 Feb 2025 02:33:38 +0000 (02:33 +0000)
This means in

   bin/samba-tool spn -h -V

the -V takes precedence over the -h, as with the 'net' tool.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15770

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz>
python/samba/netcmd/__init__.py
selftest/knownfail.d/samba-tool--version

index 3f9cb3276eb6680311990ea0cd1068e30e4e2b04..9aa4664418a5ced69e6a7ade44bdf0ee8d8df30f 100644 (file)
@@ -446,7 +446,10 @@ class SuperCommand(Command):
                 sub = self.subcommands[a]
                 return sub._resolve(sub_path, *sub_args, outf=outf, errf=errf)
 
-            elif a in ['--help', 'help', None, '-h', '-V', '--version']:
+            if a in ['-V', '--version']:
+                return (self, [a])
+
+            if a in ['--help', 'help', None, '-h']:
                 # we pass these to the leaf node.
                 if a == 'help':
                     a = '--help'
@@ -457,7 +460,7 @@ class SuperCommand(Command):
             print("%s: no such subcommand: %s\n" % (path, a), file=self.outf)
             return (self, [])
 
-        # We didn't find a subcommand, but maybe we found e.g. --version
+        # We didn't find a subcommand, but maybe we found e.g. --help
         if not deferred_args:
             print("%s: missing subcommand\n" % (path), file=self.outf)
         return (self, deferred_args)
index 858cc19b848f3f9293b64fba353eab5c73f607cf..f02938dec8f40de29bc356569a3866a342d57569 100644 (file)
@@ -1,4 +1,2 @@
 ^samba\.tests\.samba_tool\.help\.samba\.tests\.samba_tool\.help\.HelpTestCase\.test_help_version\(none\)
-^samba\.tests\.samba_tool\.help\.samba\.tests\.samba_tool\.help\.HelpTestCase\.test_version_beats_help\(none\)
 ^samba\.tests\.samba_tool\.help\.samba\.tests\.samba_tool\.help\.HelpTestCase\.test_help_version\(fileserver\)
-^samba\.tests\.samba_tool\.help\.samba\.tests\.samba_tool\.help\.HelpTestCase\.test_version_beats_help\(fileserver\)