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

Add 'quiet' or 'silent' option for using httpie in scripts #926

Closed
paulolieuthier opened this issue Jun 3, 2020 · 12 comments
Closed

Add 'quiet' or 'silent' option for using httpie in scripts #926

paulolieuthier opened this issue Jun 3, 2020 · 12 comments
Labels
enhancement New feature or enhancement help wanted Extra attention is needed

Comments

@paulolieuthier
Copy link

Simple flag to avoid unnecessary output when using inside scripts.

@jkbrzt jkbrzt added enhancement New feature or enhancement help wanted Extra attention is needed labels Jun 8, 2020
@jkbrzt
Copy link
Member

jkbrzt commented Jun 8, 2020

Rationale: Why do many commands provide a “quiet” option?

We can handle this by replacing our env.stdout and env.stderr with os.devnull at the appropriate moment. Instead of touching os.devnull directly at runtime, though, it should be added as Environment.devnull like we do with the standard streams:

https://github.com/jakubroztocil/httpie/blob/492687b0dafb7bec0d6281d019bb5f4f60439346/httpie/context.py#L32-L35

…and from that point only reference env.devnull. This will make it possible to write good tests. So basically there should only be one conditional somewhere and all existing behavior should remain intact.

@paulolieuthier
Copy link
Author

What should the flag be?

@jkbrzt
Copy link
Member

jkbrzt commented Jun 8, 2020

@paulolieuthier --quiet sounds pretty standard

@jkbrzt
Copy link
Member

jkbrzt commented Jun 8, 2020

@velezbeltran
Copy link
Contributor

Hey! Is someone working on this issue or can it be taken?

@jkbrzt
Copy link
Member

jkbrzt commented Jun 8, 2020

@nb2838 I’m not. So, unless @paulolieuthier is looking into this, it should be up for grabs.

@paulolieuthier
Copy link
Author

Go ahead @nb2838! I'm looking forward to the release :)

@YKo20010
Copy link

@nb2838 Are you still working on this? I'd like to pick up this issue if not!

@velezbeltran
Copy link
Contributor

Yes currently working on it :)

@velezbeltran
Copy link
Contributor

I've been working on the problem and I think I have a working solution. My only problem thus far is that I don't know at which point precisely to close the os.devnull file. If I don't close it and let the job be done by the garbage collectore my code works fine. However, when I try closing it by adding a
finally: env.dev.null.close() at the end of main in core.py I get an error if I use --download option. I was wondering if you have any suggestions for dealing with this issue.

@jkbrzt
Copy link
Member

jkbrzt commented Jun 27, 2020

@nb2838 please open a PR and I’ll take a look

@marcelo-r
Copy link

#945 was merged and closed.

@jkbrzt jkbrzt closed this as completed Sep 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or enhancement help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants