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

Support file-stored parser arguments? #36

Open
clagraff opened this issue Dec 7, 2016 · 2 comments
Open

Support file-stored parser arguments? #36

clagraff opened this issue Dec 7, 2016 · 2 comments
Labels

Comments

@clagraff
Copy link
Owner

clagraff commented Dec 7, 2016

Derived from: https://docs.python.org/dev/library/argparse.html#fromfile-prefix-chars

Do we want to allow for using a certain prefix-character(s) to indicate that a file being specified needs to be read, and have each line added as individual arguments to the parser, in place of the original argument.

Here is the python example:

>>> with open('args.txt', 'w') as fp:
...     fp.write('-f\nbar')
>>> parser = argparse.ArgumentParser(fromfile_prefix_chars='@')
>>> parser.add_argument('-f')
>>> parser.parse_args(['-f', 'foo', '@args.txt'])
Namespace(f='bar')

So, the library could do something similar:

parser.FromFilePrefix("@")

Which would expand the file, line by line, to individual arguments.
Is this worth implementing? I have never heard of anyone using this in practice.

@clagraff
Copy link
Owner Author

clagraff commented Dec 7, 2016

Also of note: https://docs.python.org/dev/library/argparse.html#type
Should probobly support a "file" option value type.

@clagraff
Copy link
Owner Author

clagraff commented Dec 8, 2016

Changing to a question.

@clagraff clagraff changed the title Support file-stored parser arguments. Support file-stored parser arguments? Dec 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant