Skip to content

Conversation

@bitdancer
Copy link
Member

@bitdancer bitdancer commented Sep 4, 2017

This adds support for parsing a command line where options and positionals are intermixed as is common in many unix commands. This is paul.j3's patch with a few tweaks.

https://bugs.python.org/issue14191

@zware
Copy link
Member

zware commented Sep 5, 2017

Looks reasonable to me, but Travis is unhappy with the docs change.

@bitdancer bitdancer force-pushed the parse_intermixed_args branch from 0a178e1 to 573a9ce Compare September 6, 2017 01:09
Copy link
Member

@warsaw warsaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few comments. Fix or ignore and land it!

.. method:: ArgumentParser.parse_intermixed_args(args=None, namespace=None)
.. method:: ArgumentParser.parse_known_intermixed_args(args=None, namespace=None)

A number of unix commands allow the user to intermix optional arguments with
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unix perhaps?

>>> parser.add_argument('--foo')
>>> parser.add_argument('cmd')
>>> parser.add_argument('rest', nargs='*', type=int)
>>> parser.parse_known_args('cmd1 1 --foo bar 2 3'.split())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It says cmd above, but cmd1 here and below. Is that intentional?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants