cmd: json behavior for get-block-headers*
Signed-off-by: Ciro S. Costa <utxobr@protonmail.com>
This commit is contained in:
parent
17445423a6
commit
96063a2959
|
@ -51,8 +51,11 @@ func (c *getBlockHeaderCommand) RunE(_ *cobra.Command, _ []string) error {
|
|||
return fmt.Errorf("get block header by hash: %w", err)
|
||||
}
|
||||
|
||||
c.pretty(resp.BlockHeaders)
|
||||
if c.JSON {
|
||||
return display.JSON(resp)
|
||||
}
|
||||
|
||||
c.pretty(resp.BlockHeaders)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -61,6 +64,10 @@ func (c *getBlockHeaderCommand) RunE(_ *cobra.Command, _ []string) error {
|
|||
return fmt.Errorf("get block header by height: %w", err)
|
||||
}
|
||||
|
||||
if c.JSON {
|
||||
return display.JSON(resp)
|
||||
}
|
||||
|
||||
c.pretty([]daemon.BlockHeader{resp.BlockHeader})
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -63,6 +63,10 @@ func (c *getBlockHeadersRangeCommand) RunE(_ *cobra.Command, _ []string) error {
|
|||
return fmt.Errorf("get block header by height: %w", err)
|
||||
}
|
||||
|
||||
if c.JSON {
|
||||
return display.JSON(resp)
|
||||
}
|
||||
|
||||
c.pretty(resp.Headers)
|
||||
return nil
|
||||
}
|
||||
|
|
Reference in a new issue