Skip to content

Commit a641103

Browse files
authored
Have chain:power support --json flag (#5187)
This makes chain:power standard and return JSON when you pass in --json flag and adds the --color flag support as well.
1 parent 3c45707 commit a641103

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

ironfish-cli/src/commands/chain/power.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
import { FileUtils } from '@ironfish/sdk'
55
import { Args, Flags } from '@oclif/core'
66
import { IronfishCommand } from '../../command'
7+
import { ColorFlag, ColorFlagKey } from '../../flags'
78

89
export default class Power extends IronfishCommand {
910
static description = "show the network's mining power"
11+
static enableJsonFlag = true
1012

1113
static flags = {
14+
[ColorFlagKey]: ColorFlag,
1215
history: Flags.integer({
1316
required: false,
1417
description:
@@ -23,14 +26,13 @@ export default class Power extends IronfishCommand {
2326
}),
2427
}
2528

26-
async start(): Promise<void> {
29+
async start(): Promise<unknown> {
2730
const { flags, args } = await this.parse(Power)
28-
const { block } = args
2931

3032
const client = await this.connectRpc()
3133

3234
const data = await client.chain.getNetworkHashPower({
33-
sequence: block,
35+
sequence: args.block,
3436
blocks: flags.history,
3537
})
3638

@@ -39,5 +41,7 @@ export default class Power extends IronfishCommand {
3941
this.log(
4042
`The network power for block ${data.content.sequence} was ${formattedHashesPerSecond} averaged over ${data.content.blocks} previous blocks.`,
4143
)
44+
45+
return data.content
4246
}
4347
}

0 commit comments

Comments
 (0)