-
Notifications
You must be signed in to change notification settings - Fork 114
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
Single hyphen/dash argument for indicating stdin #434
Comments
I'm thinking, if there were a mechanism for specifying expected constants, one could use that to both expect a single dash I noticed |
For now, I ended up going with: data PathArg path = StdinArg | PathArg path
Opt.argument
(Opt.maybeReader parsePathArg)
(mconcat [Opt.metavar "(-|<csv-path>)"])
parsePathArg "-" = Just StdinArg
parsePathArg path = Just (PathArg path) |
That's more or less what I would have suggested. |
There's a solution to this which you've figured out for yourself, but obviously this could be better documented. I'll add a page to the wiki for it when I get some time. |
Thanks! And a built-in constant parser may be useful in the future, too, as my solution is rather verbose. |
Hey
Thanks for you continued maintenance of Optparse Applicative!
I'm having trouble finding a way to specify a single
-
as an expected value, a pattern used to refer to reading from standard input. I'd like the help text to show(-|<path>)
and the parsing to result in either, let's say,Nothing
given-
on the command line andJust path :: Maybe FilePath
if a path other than-
was given. Is that possible at the level of Optparse?In other words, I'm looking for something to replace
…
with:This should then permit invoking an app with
./foo -
to read from stdin and./foo file
to read fromfile
, with the--help
text nicely differentiating the two use-cases.Thanks in advance!
The text was updated successfully, but these errors were encountered: