@@ -3,6 +3,8 @@ import {MinterApiService} from '../../services/minter-api/minter-api.service';
33import { JsonPatches } from "../../utils/JsonPatches" ;
44
55import { search } from 'jmespath'
6+ import { MagicPipConvert } from "../../questions/MagicPipConvert" ;
7+
68// import * as jmespath from 'jmespath'
79
810@SubCommand ( {
@@ -19,27 +21,38 @@ export class CandidateCommand extends CommandRunner {
1921
2022 async run (
2123 inputs : string [ ] ,
22- options : { height ?: number ; not_show_stakes ?: boolean ; config : string ; patch ?: string ; patches : boolean ; pretty : boolean } ,
24+ options : {
25+ height ?: number ;
26+ not_show_stakes ?: boolean ;
27+ config : string ;
28+ patch ?: string ;
29+ patches : boolean ;
30+ pretty : boolean
31+ } ,
2332 ) : Promise < void > {
2433 // const {patch, config} = options;
2534 const candidate = inputs [ 0 ] ;
2635 const minterApi = new MinterApiService ( options . config ) ;
2736
2837 minterApi . api ( ) . getCandidateGrpc ( candidate , options . not_show_stakes , options . height ) . then ( ( r ) => {
2938 const result = r . toObject ( )
30- let out : any ;
39+ let out : any ;
40+ // const mpc = new MagicPipConvert()
3141 if ( options . patches ) {
3242 new JsonPatches ( ) . printPropertyNames ( result )
3343 } else if ( options . patch && options . patch . length > 0 ) {
3444 // out=result[options.patch]
35- out = search ( result , options . patch )
45+ out = search ( result , options . patch )
46+ } else {
47+ out = result
48+ }
49+ out = new MagicPipConvert ( ) . replaceLongNumericStrings ( out )
50+ if ( ! options . pretty ) {
51+ process . stdout . write ( JSON . stringify ( out ) ) ;
3652 } else {
37- out = result
53+ console . warn ( ( out ) )
54+ // console.warn(out)
3855 }
39- if ( ! options . pretty )
40- process . stdout . write ( JSON . stringify ( out ) ) ;
41- else
42- console . warn ( out )
4356 }
4457 )
4558 . catch ( console . log ) ;
@@ -92,6 +105,7 @@ export class CandidateCommand extends CommandRunner {
92105 parsePatches ( val : string ) : boolean {
93106 return JSON . parse ( val ) ;
94107 }
108+
95109 @Option ( {
96110 flags : '--pretty [boolean]' ,
97111 description : 'Pretty' ,
0 commit comments