pipreqs icon indicating copy to clipboard operation
pipreqs copied to clipboard

Print to stdout by default

Open timwis opened this issue 7 years ago • 6 comments

Thanks for this tool! I just wanted to suggest that perhaps pipreqs print to stdout by default, allowing you to redirect to a file via:

pipreqs > requirements.txt

But this would let you check the results before writing (or overwriting) to the file, by seeing it in your terminal first. Another option is to use a -o requirements.txt flag.

Just a suggestion :)

timwis avatar Oct 09 '17 15:10 timwis

While this isn't the default, it is possible using the --print flag. When using this flag, the output is written to stdout rather than a file. If you'd like to change the filename without printing to stdout, you can do so with the --savepath flag.

The "standard" way to provide these options in other tools are --output filename and --output - (for stdout). Adding these as synonyms for the existing options may make this behavior more conventionally discoverable.

jonafato avatar Oct 20 '17 15:10 jonafato

@timwis do the existing options address your use case?

jonafato avatar Oct 23 '17 04:10 jonafato

Sure, it works just fine -- I just wanted to suggest flipping the default to be more similar to other unix CLI tools. But just an opinion/suggestion -- no right or wrong answer. I'll close for now :)

timwis avatar Oct 24 '17 12:10 timwis

I think this makes sense for a future release (one that would include breaking changes). Just wanted to make sure you knew these options existed today.

jonafato avatar Oct 24 '17 14:10 jonafato

Thanks for this tool very much! But I wonder if there can be a option such as --no-info-output to cancel the output information "Successfully saved requirements file in xxx"? Because I want to use the pipreqs instruction by subprocess in my python project but I just don't want to output this info in my shell. Just a suggestion.

KKZ20 avatar Mar 14 '22 02:03 KKZ20

I'd like to second what KKZ20 said here (both the message of gratitude and the remark about the info output). It's a bit strange in my opinion for an info message specifying success to be printed to stderr in the first place, but I suppose it's better than mixing it in with the output. In general it would be nice if this tool acted more similarly to standard UNIX tools, printing the results to stdout by default, printing to stderr only when an error occurs and just printing nothing if it's successful but there are no dependencies to print. The indication of success seems rather redundant to me. It should be conveyed through the exit code instead.

Well, at least this can be dealt with using the currently available options. Once again, thanks for making this. =)

TomerGodinger avatar Apr 19 '22 10:04 TomerGodinger