Skip to content

Support file-stored parser arguments? #36

Description

@clagraff

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions