Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double dash positional argument separator breaks parsing #114

Open
rendaw opened this issue Feb 23, 2018 · 0 comments
Open

Double dash positional argument separator breaks parsing #114

rendaw opened this issue Feb 23, 2018 · 0 comments

Comments

@rendaw
Copy link

rendaw commented Feb 23, 2018

I looked around to see if this was addressed somewhere but I'm afraid I don't know what to call this feature in the first place so searching was difficult.

With the code

import configargparse as argparse
p = argparse.ArgumentParser()
p.add_argument('--a')
p.add_argument('z')
print(p.parse_args(config_file_contents='a=x'))

running python a.py one outputs:

Namespace(a='x', z='one')

but python a.py -- one fails with:

usage: a.py [-h] [--a A] z
a.py: error: unrecognized arguments: --a x

If used with an nargs='*' parameter this causes the config file option to be parsed as part of that parameter:

import configargparse as argparse
p = argparse.ArgumentParser()
p.add_argument('--a')
p.add_argument('z', nargs='*')
print(p.parse_args(config_file_contents='a=x'))
$ python a.py -- one
Namespace(a=None, z=['one', '--a', 'x'])
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

No branches or pull requests

1 participant