Disabling interspersed args in cfg

Registered by Mark McLoughlin

Nova currently relies on cfg being implemented with optparse because it uses optparse's disable_interspersed_args()

The use case for this is if you do:

  $> nova-manage --verbose create --project foo --user bar

you want invoking ConfigOpts() to return ['create', '--project', 'foo', '--user', 'bar'] as the "extra" args rather than aborting when it doesn't recognize the --project arg.

This is a reasonable use case for cfg to support and it should just have {disable,enable}_interspersed_args() methods

If we switch to argparse, we'll do something like this:

  parser.add_argument('--verbose')
  ...
  parser.add_argument('extra_args', nargs=argparse.REMAINDER if disable_interspersed_args else '*')
  ...
  ns = parser.parse_args(...)
  extra_args = ns.extra_args

i.e. we will need an 'extra_args' multi-value positional argument in any case and we'll just pass nargs=REMAINDER if we want trailing options to be included in the extra args

Blueprint information

Status:
Complete
Approver:
Mark McLoughlin
Priority:
Medium
Drafter:
Mark McLoughlin
Direction:
Approved
Assignee:
Mark McLoughlin
Definition:
Approved
Series goal:
Accepted for essex
Implementation:
Implemented
Milestone target:
milestone icon 2012.1
Started by
Mark McLoughlin
Completed by
Mark McLoughlin

Related branches

Sprints

Whiteboard

Addressed by: https://review.openstack.org/3298
    Add support to cfg for disabling interspersed args

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.