Open denis-sokolov opened 9 years ago
I was trying to enable piping in the shell. Are you saying I should expose a flag that allows one to pipe, only if the flag is provided? It seems a flag to turn off the behavior might make more sense. What do you think?
Oh, you're the author of both modules! I missed that!
I believe that users of gitlike-cli
(authors of modules like eclint
)
need to handle stdin differently than other arguments.
Whether the user calls fs.readFile
or glob.replace
, he needs to treat the stdin differently.
If that is the case, he needs to be aware of the chance stdin is passed in.
If he is aware of that, it means he's read the paragraph about it in the docs,
meaning he can easily opt-in by enabling the flag.
All the users who are not aware stdin might be passed in cannot be asked to opt-in.
They have seen an example where args.files
is a list of strings and they happily
use gitlike-cli
until the day comes where their library blows up.
It's a nice idea to attempt to make stdin transparent, but unfortunately it does not work.
I agree with what denis-sokolov says, it is quite unexpected to have things of different types in arg.files : "strings" and "streams".
It would make more sense imo to never mix both types of parameters, but rather have 'arg.files' and 'arg.streams'
And you're saying it makes more sense to opt into the streams, right? With a --stdin
flag or something of that nature?
Yes, somethig making explicit the use of stdin.
--stdin flag, why not.
fed037ba9 has added an ability to automatically add stdin to the list of files accepted by the program. That's unexpected by developers who test their tools interactively, but whose tools later break when ran in a non-interactive environment. The documentation does not seem to mention this at all, making this a doubly unexpected surprise.
Moreover, the list of arguments is not necessarily a list of files, so adding stdin there might not be meaningful at all.
In case of
eclint
, for example, the code loops over the arguments treating them as string globs, and stdin in the list crashes the entire program.Perhaps it would make sense to revert the default behavior and make programs that are able to handle stdin opt-in explicitly?