Closed Tormenta74 closed 5 years ago
That is a great question. Which also (going one step further) would be "And how about pipes?".
As nice as it would be to have library that does everything (i.e. like systemd tries to do absolutely everything), I think in this specific case it would be better to keep this library do what it is intended to do, namely -- parsing command line arguments.
You always can achieve the same what you want in your own code. Such as:
s := p.String("s", "string", &argparse.Options{...})
p.Parse(os.Args)
switch *s {
case "stdin":
// read value from stdin
default:
// use value as provided on CLI
}
Also on Unix systems at least the de-facto old standing standard is to use -
for stdin, though in your app you can do this at your own discretion.
I'm not quite sure of the size of my request, but here goes.
Looking at the implementation I see that the default should be a string, it being the path to the file to open, but I can't seem to make that point to the "real" standard streams. Perhaps it could be hardcoded that the strings "stdin", "stdout", "stderr" in the Option's Default for the File trigger that the file pointer points to
os.Stdin / Stderr / Stdout
?