-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Allow more flexible configuration of the output steam (stdout vs. stderr) #1788
Comments
@tzakharko hi thanks for the issue, would you be willing to send us a pr that makes this change? thanks |
@Dylan-DPC I am afraid I am neither familiar enough with the Clap codebase nor with Rust to figure out the best way of doing it at the moment. I suppose one would hav etc decouple the output settings from the I have opened the issue mainly because @pksunkara asked me to do so in a discussion thread. I understand this might be lower priority. |
@tzakharko that's fine we will mentor you if needed. It's a good way to learn rust :D |
@Dylan-DPC fair enough :) I will have a look, but I won't be able to allocate any time for this short term. I will put it on my agenda and let's keep the issue open for now. |
I imagine this would be much trickier to implement, but how do folks feel about allowing arbitrary I've been working on a CLI tool that incorporates paging by conditionally targeting a paging child process or the configured terminal. |
@tzakharko I believe clap is only reporting @olson-sean-k some quick thoughts on this
|
I am leaning towards rejecting this until we have a use case that explains why output going to stdout for explicit user interactions is interfering with an applications behavior (especially since there are cases where people want their This isn't to make a statement of whether we want this or not but because we are specifically looking at finding ways to trim the API of clap which also raises the bar for changes that expand the API. |
An example use case is if a command is leveraging shell hooks to |
I've not dealt with shell hooks to |
The shell hook is the main interface to the program, so the user would be expected to run The automatic function prog() {
result="$(prog_bin $@)" # Run `prog_bin` with the supplied arguments, capturing stdout but leaving stderr to the tty
[[ -n $result ]] && cd $result # If anything was printed to stdout, `cd` to it.
} |
@epage Sorry for replying late and thanks for following this through. I have to be quite honest that I do not remember what was the actual problem that made me open this issue, it was two years ago and couldn't find any relevant notes. I think it had to do with the fact that some outputs did not pipe correctly when uses as part of a complex unix command sequence, but we are not currently using these tools so I guess that's all I can say. At any rate, I would be fine with this being closed, as it is not a critical issue for us at the moment. But I gather from the comments that some other folks are running into real-world issues, so maybe they will have a better motivating example. |
It seems that version
I believe the use case described in my previous comment has precedent and falls into this category. It is not possible to (comprehensively) implement
I feel that Regarding styling, perhaps detection and styles could be feature gated. When the styling feature is enabled, Any thoughts on something like this post- |
Requiring clap to take on lifetimes again to pass around the streams would be a no-go. For you printing everything yourself, my hope is that with the new styling API I plan to focus on for 4.x, we'll be able to provide you a
My priority is going to be on the issues currently targeting 4.x. People are free to come up with a design for additional APIs but the further from my priorities, the less attention it will get. There will also be a high bar for impact on all users. |
Describe your use case
Some command line tools are used exclusively as components within larger configurations and their
stdout
might be piped into other tools.Clap
is currently hard-coded inError::use_stderr()
to print certain messages (e.g. the help block) tostdout
, which might lead to surprising behavior.Describe the solution you'd like
It would be nice to have an option in configuring the behavior of
Error:: use_stderr()
. maybe a configuration option inApp
that would override the default behavior, e.g.:Alternatives, if applicable
I am currently intercepting all
clap
messages and printing them manually like this:but it feels a bit hacky to me.
The text was updated successfully, but these errors were encountered: