-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix(commands): support --enc=json in stat #5620
Conversation
License: MIT Signed-off-by: Overbool <overbool.xu@gmail.com>
@magik6k could u help me review it? |
|
||
if polling { | ||
fmt.Fprintln(os.Stdout, "Total Up Total Down Rate Up Rate Down") | ||
// print only once in `--poll` flag | ||
once.Do(func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work for multiple invocations of the command, not sure what's the best way to do that. cc @keks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The proper way to do this is using PostRun
. Encoders are for processing individual elements, while PostRun
is passed the stream that is emitted by Run
and can do transport (e.g. cli or http) specific presentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify: I think we need a second PostRunFunc
in the PostRun
map with index cmds.JSON
.
} | ||
}, | ||
|
||
fmt.Fprintf(os.Stdout, "%8s ", humanize.Bytes(uint64(bs.TotalOut))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be also probably be printing into the writer instead of directly to Stdout.
(closing due to inactivity) |
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'
Fixes: #5594
License: MIT
Signed-off-by: Overbool overbool.xu@gmail.com