trove help create has positional arguments in incorrect spot

Bug #1243981 reported by Anita Kuno
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-troveclient
Fix Released
Medium
Auston McReynolds

Bug Description

trove help create shows the positional arguments after the optional arguments. The positional arguments need to be placed before the optional arguments for the command to execute.

usage: trove create [--size <size>]
                    [--databases <databases> [<databases> ...]]
                    [--users <users> [<users> ...]] [--backup <backup>]
                    [--availability_zone <availability_zone>]
                    <name> <flavor_id>

Revision history for this message
Craig Vyvial (cp16net) wrote :

I think this bug is actually the way argparse handles the optional/positional arguments.

On the surface i do not see a way of fixing this bug. Here is the code in argparse that prints the usage.
http://hg.python.org/cpython/file/default/Lib/argparse.py#l314

Revision history for this message
Anita Kuno (anteaya) wrote :
affects: trove → python-troveclient
Changed in python-troveclient:
assignee: nobody → Auston McReynolds (amcrn)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-troveclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/53792

Changed in python-troveclient:
status: New → In Progress
Revision history for this message
Auston McReynolds (amcrn) wrote :

To elaborate, this problem only surfaces if your command has positional argument(s) immediately after an optional argument that is a narg='*' (or any narg other than narg='?'). In the 'create' scenario, databases and users are both narg='*'.

The proposed fix formats the usage string such that the positional arguments precede the optional.

i.e. instead of:

usage: trove create <name> <flavor_id>
                    [--size <size>]
                    [--databases <databases> [<databases> ...]]
                    [--users <users> [<users> ...]] [--backup <backup>]
                    [--availability_zone <availability_zone>]

you get:

usage: trove create [--size <size>]
                    [--databases <databases> [<databases> ...]]
                    [--users <users> [<users> ...]] [--backup <backup>]
                    [--availability_zone <availability_zone>]
                    <name> <flavor_id>

Revision history for this message
Auston McReynolds (amcrn) wrote :

doh!

I meant to say that you get:

usage: trove create <name> <flavor_id>
                    [--size <size>]
                    [--databases <databases> [<databases> ...]]
                    [--users <users> [<users> ...]] [--backup <backup>]
                    [--availability_zone <availability_zone>]

vs:

usage: trove create [--size <size>]
                    [--databases <databases> [<databases> ...]]
                    [--users <users> [<users> ...]] [--backup <backup>]
                    [--availability_zone <availability_zone>]
                    <name> <flavor_id>

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-troveclient (master)

Reviewed: https://review.openstack.org/53792
Committed: http://github.com/openstack/python-troveclient/commit/21a468dd3be820bcd83eb7b90b72f2ca48ad8530
Submitter: Jenkins
Branch: master

commit 21a468dd3be820bcd83eb7b90b72f2ca48ad8530
Author: amcrn <email address hidden>
Date: Fri Oct 25 00:12:01 2013 -0700

    Usage String has Positionals after Optionals

    print positionals before optionals in the usage string to help
    users avoid argparse nargs='*' problems.

    ex: 'trove create --databases <db_name> <name> <flavor_id>'
    fails with 'error: too few arguments', but this succeeds:
    'trove create <name> <flavor_id> --databases <db_name>'

    Change-Id: I400c9f0ca5580bd287c5f3bcf935352e88071bc8
    Closes-Bug: #1243981

Changed in python-troveclient:
status: In Progress → Fix Committed
Changed in python-troveclient:
status: Fix Committed → Fix Released
importance: Undecided → Medium
milestone: none → python-troveclient-v1
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.