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

feat: add command output/error option #223

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

schomatis
Copy link
Contributor

@schomatis schomatis commented Jan 18, 2022

Add an option to save command output to a file instead of the stdout argument (which was always set to stdout by go-ipfs consumer). We have removed the option and assumed stdout except the option is set (this was intended to loudly flag the output is being set by an option since the argument could be misleadingly overridden, but we can restore the argument and have the two coexist).

Used in ipfs/kubo#8683.

Related to ipfs/kubo#8335.

Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect stdout is not enough. My concern is that stderr would not end up in the (empty) file, but would go to terminal:

$ ipfs id --command-output=stdout.txt
Error: no IPFS repo found in /home/lidel/tmp/go-ipfs-out.
please run: 'ipfs init'

$ ipfs get invalidcid --command-output=stdout.txt
Error: invalid path "invalidcid": selected encoding not supported

If someone runs a command in bash script, they may not monitor stderr and the message may be lost.

Perhaps an elegant way of handling this is to have explicit --stdout (or --output) and --stderr (or --errors) ?

$ ipfs get invalidcid --stdout=stdout.txt --stderr=stderr.txt
$ cat stdout.txt 
$ cat stderr.txt
Error: invalid path "invalidcid": selected encoding not supported

cc @aschmahmann you may have better intuition about what would be the most useful on windows

@schomatis
Copy link
Contributor Author

@lidel Added error output option (we can review the option names at the end; I'm leaving for now the conspicuous --command-output/error for visibility).

@schomatis schomatis requested a review from lidel January 28, 2022 13:51
@schomatis schomatis changed the title feat: add command output option feat: add command output/error option Jan 28, 2022
@BigLep BigLep marked this pull request as ready for review March 10, 2022 03:23
opts.go Outdated Show resolved Hide resolved
Co-authored-by: Marcin Rataj <[email protected]>
@lidel lidel modified the milestones: go-ipfs 0.13, Best Effort Track Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: 🔎 In Review
Development

Successfully merging this pull request may close these issues.

3 participants