11import { Option , CommandRunner , SubCommand } from 'nest-commander' ;
22import { MinterApiService } from '../../services/minter-api/minter-api.service' ;
3- import { JsonPatches } from "../../utils/JsonPatches" ;
4-
5- import { search } from 'jmespath'
6- import { MagicPipConvert } from "../../questions/MagicPipConvert" ;
7-
8- // import * as jmespath from 'jmespath'
3+ import { ContentExporter } from "../../services/ContentExporter" ;
94
105@SubCommand ( {
116 name : 'candidate' ,
@@ -14,8 +9,9 @@ import {MagicPipConvert} from "../../questions/MagicPipConvert";
149 description : 'Candidate returns candidate’s info by provided public key' ,
1510} )
1611export class CandidateCommand extends CommandRunner {
12+ private skip_pip2bip = false ;
1713
18- constructor ( ) {
14+ constructor ( private contentExporter : ContentExporter ) {
1915 super ( ) ;
2016 }
2117
@@ -36,29 +32,15 @@ export class CandidateCommand extends CommandRunner {
3632
3733 minterApi . api ( ) . getCandidateGrpc ( candidate , options . not_show_stakes , options . height ) . then ( ( r ) => {
3834 const result = r . toObject ( )
39- let out : any ;
40- // const mpc = new MagicPipConvert()
41- if ( options . patches ) {
42- new JsonPatches ( ) . printPropertyNames ( result )
43- } else if ( options . patch && options . patch . length > 0 ) {
44- // out=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 ) ) ;
52- } else {
53- console . warn ( ( out ) )
54- // console.warn(out)
55- }
35+ this . contentExporter . print ( result , this . skip_pip2bip , options )
5636 }
5737 )
5838 . catch ( console . log ) ;
5939 return Promise . resolve ( undefined ) ;
6040 }
6141
42+
43+
6244 @Option ( {
6345 flags : '--height [number]' ,
6446 name : 'Height' ,
@@ -114,4 +96,16 @@ export class CandidateCommand extends CommandRunner {
11496 parsePretty ( val : string ) : boolean {
11597 return JSON . parse ( val ) ;
11698 }
99+
100+ @Option ( {
101+ flags : '--skip_pip2bip' ,
102+ name : 'skip_pip2bip' ,
103+ description : 'Skip convert PIP to BIP' ,
104+ defaultValue : false ,
105+ } )
106+ parseSkipPip2Bip ( val : string ) : boolean {
107+ this . skip_pip2bip = true ;
108+ return JSON . parse ( val ) ;
109+ }
110+
117111}
0 commit comments