Make help message more accurate and user-friendly

Now in python-fuelclient if we try to get help message
for specific command with '--help' option, e.g.:

      fuel2 node list --help

the output result looks very ugly, because it prints
all available commands in fuel2 instead of detailed
description for exact command. Also we have similar
behavior if we try to specify non-existing command.
This patch makes help message more accurate and
user-friendly, e.g.:

      #fuel2 env add nodes --help

usage: fuel2 env add nodes [-h] -e ENV -n NODES [NODES ...]
                           -r ROLES [ROLES ...]

Adds nodes to an environment with the specified roles.

optional arguments:
  -h, --help            show this help message and exit
  -e ENV, --env ENV     Id of the environment to add nodes to
  -n NODES [NODES ...], --nodes NODES [NODES ...]
                        Ids of the nodes to add.
  -r ROLES [ROLES ...], --roles ROLES [ROLES ...]
                        Target roles of the nodes.

     #fuel2 non-existing --help

Unknown command ['non-existing']

Change-Id: I89afb39d92ffb01c37fbf558e6d62091ac6112e7
Partial-Bug: 1629285
This commit is contained in:
tivaliy 2016-10-19 14:20:04 +03:00
parent 496968758f
commit 169dda2d6b
1 changed files with 2 additions and 1 deletions

View File

@ -75,6 +75,7 @@ def main(argv=sys.argv[1:]):
fuelclient_app = FuelClient(
description='Command line interface and Python API wrapper for Fuel.',
version='10.0.0',
command_manager=CommandManager('fuelclient', convert_underscores=True)
command_manager=CommandManager('fuelclient', convert_underscores=True),
deferred_help=True
)
return fuelclient_app.run(argv)