-
Notifications
You must be signed in to change notification settings - Fork 42
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
PostRun is an awkward fit for CLI output #115
Labels
kind/enhancement
A net-new feature or improvement to an existing feature
Milestone
Comments
Stebalien
added
the
kind/enhancement
A net-new feature or improvement to an existing feature
label
Aug 10, 2018
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
jbouwman
pushed a commit
to jbouwman/go-ipfs-cmds
that referenced
this issue
Aug 19, 2021
Several open issues mention problems with interaction of the global `--encoding=` flag and the Encoders and PostRun fields of command structs. This branch contains experimental refactors that explore approaches to consistent command execution patterns across offline, online and http modes. Specific tickets: - ipfs/kubo#7050 json encoding for `ls` - ipfs/kubo#1121 json encoding for `add` - ipfs/kubo#5594 json encoding for `stats bw` - ipfs#115 postrun design Possibly related: - ipfs/kubo#6640 global flags on subcommands Incomplete PRs: - ipfs/kubo#5620 json for 'stat'
This was referenced Aug 19, 2021
jbouwman
added a commit
to jbouwman/go-ipfs-cmds
that referenced
this issue
Aug 21, 2021
Following the approach described in ipfs#115, define a new method signature on `Command` that supports full processing of the `Response` object when text encoding is requested. Add an encoding check and dispatch to DisplayCLI in local, http client, and http handler code paths. Unblocks resolution of `encoding` option processing in multiple go-ipfs issues. - ipfs/kubo#7050 json encoding for `ls` - ipfs/kubo#1121 json encoding for `add` - ipfs/kubo#5594 json encoding for `stats bw`
jbouwman
added a commit
to jbouwman/go-ipfs-cmds
that referenced
this issue
Sep 8, 2021
Following the approach described in ipfs#115, define a new method signature on `Command` that supports full processing of the `Response` object when text encoding is requested. Add an encoding check and dispatch to DisplayCLI in local, http client, and http handler code paths. Unblocks resolution of `encoding` option processing in multiple go-ipfs issues. - ipfs/kubo#7050 json encoding for `ls` - ipfs/kubo#1121 json encoding for `add` - ipfs/kubo#5594 json encoding for `stats bw`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When writing CLI output, we often want to write to stdout/stderr, sometimes even controlling terminal output. For commands that just need to format to stdout, we can use a text marshaler. However, for commands that need to write to some parts to stderr and/or control the terminal, that doesn't really fit.
So, in practice, we use a
PostRun
function. However, that isn't a fit either as it expects us to transform a response emitter.Currently, we just hack it by writing to stdout/stderr anyways but I'd like a better option.
So, I'd like to:
Encoders
when we don't need anything fancy (just text and a terminal error).func(res cmds.Response, stdout, stderr io.Writer) error
.In the future, we could add additional display functions for different interfaces (e.g., browsers) but this seems like a good starting point. Thoughts?
The text was updated successfully, but these errors were encountered: