argparse
argparse copied to clipboard
expect File arg to take standard input / output stream as a value
When I define a File
arg (like following) to specify an input file,
-i <input-file>
I wish we can specify the -
value to input from the standard input stream. However, it will report error now.
if it's defined with a String
arg, the help message will display like -i "<value>"
(cannot tell this should be a file), not as expected very much.
It is the same case for the output file. I wish to specify the -
value to output to standard output stream.
You can provide Options.Help
and write there that it must be a file, in addition you can add validation to the argument that will check whether string is a file or if it is "-".
I can see how it could be useful, but then would also need to account for ability to pipe stdin etc, which is better handled from application code than from this library.
I've added File
early on, but it is rather complex to deal with and there are many edge cases where it can fail. It currently only exists for backward compatibility and I myself stopped using this argument type and just use String
instead.
I think it can be done with minimal change, PR is welcome.