cmd: json behavior for get-block-headers*

Signed-off-by: Ciro S. Costa <utxobr@protonmail.com>
This commit is contained in:
Ciro S. Costa 2021-09-18 20:16:55 +00:00
parent 17445423a6
commit 96063a2959
2 changed files with 12 additions and 1 deletions

View file

@ -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
}

View file

@ -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
}