-
Notifications
You must be signed in to change notification settings - Fork 19
Add JSON format for account show and rofl machine show
#677
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
base: master
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for oasisprotocol-cli canceled.
|
911b53c to
1d0ac28
Compare
1d0ac28 to
caa5bd3
Compare
oasis account showaccount show and rofl machine show
| cobra.CheckErr("Machine instance not found.\nTip: This often happens when instances expire. Run `oasis rofl deploy --replace-machine` to rent a new one.") | ||
| switch common.OutputFormat() { | ||
| case common.FormatJSON: | ||
| fmt.Printf("{ \"error\": \"%s\" }\n", err) |
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.
cobra.CheckErr in the other case also exits the program, while this one doesn't?
| cfg := cliConfig.Global() | ||
| npa := common.GetNPASelection(cfg) | ||
|
|
||
| out := accountShowOutput{} |
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.
| out := accountShowOutput{} | |
| var out accountShowOutput |
This is prefered way for zero values.
|
|
||
| if name := common.FindAccountName(nativeAddr.String()); name != "" { | ||
| fmt.Printf("Name: %s\n", name) | ||
| out.Name = name |
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.
You can remove if as "" is zero value for Name'
| if showDelegations { | ||
| outgoingDelegations, err = c.Consensus().Staking().DelegationInfosFor(ctx, ownerQuery) | ||
| cobra.CheckErr(err) | ||
| out.OutgoingDelegations = outgoingDelegations |
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 following lines can be removed.
var (
outgoingDelegations map[staking.Address]*staking.DelegationInfo
outgoingDebondingDelegations map[staking.Address][]*staking.DebondingDelegationInfo
)
cmd/rofl/machine/show.go
Outdated
| paidUntil := time.Unix(int64(insDsc.PaidUntil), 0) | ||
| expired := !time.Now().Before(paidUntil) | ||
|
|
||
| if common.OutputFormat() == common.FormatJSON { |
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.
It would be nice to move code after if to a function for printing in text format, like is done for account show.
6a6f8a5 to
65a8648
Compare
This makes it possible to use the Oasis CLI for automation.