-h and --help revert to top level help when used in a subcommand

Bug #1444983 reported by opavlenk
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
cliff
Fix Released
Undecided
Sean Perry
python-openstackclient
Invalid
Medium
Sean Perry

Bug Description

The only way to get help output for a 'sub-command' (like `user set` or `user list`) is to insert 'help' as the first positional argument.

Like so: $ openstack help user set`

usage: openstack user set [-h] [--name <name>] [--project <project>]
                          [--password <user-password>] [--password-prompt]
                          [--email <email-address>] [--enable | --disable]
                          <user>

If using -h or --help anywhere, the "top-level" help output is printed. (the same output as `openstack help`)

$ openstack user set --help

OR

$ openstack -h user set

Will both print out the *entire* help output, with all env. properties and command options.

usage: openstack [--version] [-v] [--log-file LOG_FILE] [-q] [--debug]
                 [--os-region-name <auth-region-name>]
                 [--os-cacert <ca-bundle-file>] [--verify | --insecure]
...
Commands:
  aggregate add host Add host to aggregate
  aggregate create Create a new aggregate
  aggregate delete Delete an existing aggregate

Revision history for this message
Steve Martinelli (stevemar) wrote :

i'm a bit confused here - is the issue that the -h option isn't showing up?

Revision history for this message
Steve Martinelli (stevemar) wrote :

I run `$ openstack help user set`

Actual results:
usage: openstack user set [-h] [--name <name>] [--project <project>]
                          [--password <user-password>] [--password-prompt]
                          [--email <email-address>] [--enable | --disable]
                          <user>

summary: - Usage is not described accurately for 99% of openstack CLI sub commands
+ -h and --help are not recognized and revert to top level help
description: updated
Changed in python-openstackclient:
status: New → Confirmed
importance: Undecided → Medium
milestone: none → m9
summary: - -h and --help are not recognized and revert to top level help
+ -h and --help revert to top level help when used in a subcommand
Revision history for this message
Dean Troyer (dtroyer) wrote :

So this is the intended behaviour, -h and --help are global options and are intended to produce the help for the other global options and list the recognized commands for the selected API versions.

Help for commands is returned using the help command, which actually is an OSC command (cliff really).

Changed in python-openstackclient:
status: Confirmed → Invalid
Dean Troyer (dtroyer)
Changed in python-openstackclient:
milestone: m9 → none
Changed in python-openstackclient:
status: Invalid → Confirmed
assignee: nobody → Sean Perry (sean-perry-a)
Changed in python-openstackclient:
status: Confirmed → In Progress
Revision history for this message
Steve Martinelli (stevemar) wrote :

I'll keep this tracked in OSC too, even though we won't fix anything, i'll use this bug to track when we actually bump the cliff requirement

Changed in python-cliff:
status: New → In Progress
Revision history for this message
Steve Martinelli (stevemar) wrote :
Changed in python-cliff:
assignee: nobody → Sean Perry (sean-perry-a)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cliff (master)

Reviewed: https://review.openstack.org/201258
Committed: https://git.openstack.org/cgit/openstack/cliff/commit/?id=5d5aeb2f99410bd71904f92bf21fba7abf4ea284
Submitter: Jenkins
Branch: master

commit 5d5aeb2f99410bd71904f92bf21fba7abf4ea284
Author: Sean Perry <email address hidden>
Date: Mon Jul 13 09:00:28 2015 -0700

    Allow subcommands to accept --help when using 'deferred_help'.

    This patch changes how cliff handles help for subcommands but only when
    'deferred_help' is enabled. Currently cliff consumes --help requests at the top
    level. This means `myapp foo --help` and `myapp --help` produce the same output.
    To get help for `foo` one must use `myapp help foo`. With this change
    `myapp foo --help` will produce the same output as `myapp help foo` by
    transforming the --help request into a help subcommand one. This is only done
    when there are any options on the command line other than --help. When a top
    level --help is requested the original behavior of print_help_if_requested()
    is preserved.

    Change-Id: I628bbfc383de516045288512cc023213d723a027
    Closes-Bug: 1444983

Changed in python-cliff:
status: In Progress → Fix Committed
Revision history for this message
Steve Martinelli (stevemar) wrote :

this will be resolved when we release 1.6.0 of osc

Changed in python-openstackclient:
status: In Progress → Invalid
Changed in python-cliff:
milestone: none → 1.14.0
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.