@@ -43,7 +43,7 @@ const (
4343 selParameters
4444)
4545
46- func printEntityNodes (ctx context.Context , npa * common.NPASelection , stakingConn staking.Backend , registryConn registry.Backend , beaconConn api.Backend , entity * entity.Entity , height int64 ) error {
46+ func prettyPrintEntityNodes (ctx context.Context , npa * common.NPASelection , stakingConn staking.Backend , registryConn registry.Backend , beaconConn api.Backend , entity * entity.Entity , height int64 ) error {
4747 epoch , err := beaconConn .GetEpoch (ctx , height )
4848 if err != nil {
4949 return err
@@ -177,7 +177,14 @@ var showCmd = &cobra.Command{
177177 }
178178
179179 if entity , err := registryConn .GetEntity (ctx , idQuery ); err == nil {
180- err = printEntityNodes (ctx , npa , stakingConn , registryConn , beaconConn , entity , height )
180+ switch common .OutputFormat () {
181+ case common .FormatJSON :
182+ var jsonBytes []byte
183+ jsonBytes , err = json .MarshalIndent (& entity , "" , " " )
184+ fmt .Println (string (jsonBytes ))
185+ default :
186+ err = prettyPrintEntityNodes (ctx , npa , stakingConn , registryConn , beaconConn , entity , height )
187+ }
181188 cobra .CheckErr (err )
182189 return
183190 }
@@ -210,7 +217,14 @@ var showCmd = &cobra.Command{
210217 cobra .CheckErr (err ) // If this doesn't work the other large queries won't either.
211218 for _ , entity := range entities {
212219 if staking .NewAddress (entity .ID ).Equal (addr ) {
213- err = printEntityNodes (ctx , npa , stakingConn , registryConn , beaconConn , entity , height )
220+ switch common .OutputFormat () {
221+ case common .FormatJSON :
222+ var jsonBytes []byte
223+ jsonBytes , err = json .MarshalIndent (& entity , "" , " " )
224+ fmt .Println (string (jsonBytes ))
225+ default :
226+ err = prettyPrintEntityNodes (ctx , npa , stakingConn , registryConn , beaconConn , entity , height )
227+ }
214228 cobra .CheckErr (err )
215229 return
216230 }
0 commit comments