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

expect File arg to take standard input / output stream as a value #97

Open
xnslong opened this issue Mar 18, 2022 · 2 comments
Open

expect File arg to take standard input / output stream as a value #97

xnslong opened this issue Mar 18, 2022 · 2 comments

Comments

@xnslong
Copy link

xnslong commented Mar 18, 2022

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.

@akamensky
Copy link
Owner

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.

@akamensky
Copy link
Owner

I think it can be done with minimal change, PR is welcome.

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

No branches or pull requests

2 participants