1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-03 04:22:09 +03:00

samba-tool: fetch "no such subcommand" error and print error message

This patch especially improves the case where extra arguments are used.

Without this patch just the attributes are mentioned as invalid, if
samba-tool is called with an invalid/unknown subcommand.

Example without this patch:
  # samba-tool sites list --all
  Usage: samba-tool sites <subcommand>

  samba-tool sites: error: no such option: --all

This can be deceptive for users. Is looks like the "list" command
does not provide a "--all" option.

Example with this patch:
  # samba-tool sites list --all
  samba-tool sites: no such subcommand: list

  Usage: samba-tool sites <subcommand>
  (...)

Signed-off-by: Björn Baumbach <bb@sernet.de>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Wed Apr 29 08:08:21 UTC 2020 on sn-devel-184
This commit is contained in:
Björn Baumbach
2020-04-28 17:09:56 +02:00
committed by Andrew Bartlett
parent ae5cb7346b
commit dc280f88be

View File

@ -234,6 +234,9 @@ class SuperCommand(Command):
if subcommand in self.subcommands:
return self.subcommands[subcommand]._run(
"%s %s" % (myname, subcommand), *args)
elif subcommand not in [ '--help', 'help', None ]:
print("%s: no such subcommand: %s\n" % (myname, subcommand))
args = []
if subcommand == 'help':
# pass the request down