|
| 1 | +import {Option, CommandRunner, SubCommand} from 'nest-commander'; |
| 2 | + |
| 3 | + |
| 4 | +@SubCommand({ |
| 5 | + name: 'candidate', |
| 6 | + arguments: '<public_key>', |
| 7 | + argsDescription: {'public_key':'Public key'}, |
| 8 | + description: 'Candidate returns candidate’s info by provided public key', |
| 9 | +}) |
| 10 | +export class CandidateCommand extends CommandRunner { |
| 11 | + |
| 12 | + async run(inputs: string[], |
| 13 | + options: { height?: number, not_show_stakes?: boolean}, |
| 14 | + ): Promise<void> { |
| 15 | + |
| 16 | + console.log("candidate"); |
| 17 | + console.log(`inputs: ${inputs[0]}`); |
| 18 | + console.log(`height: ${options.height}`); |
| 19 | + console.log(`not_show_stakes: ${options.not_show_stakes}`); |
| 20 | + return Promise.resolve(undefined); |
| 21 | + } |
| 22 | + |
| 23 | + @Option({ |
| 24 | + flags: '--height [number]', |
| 25 | + name: 'Height', |
| 26 | + description: 'Blockchain state height for the current request. Optional, the last default state of the node is used', |
| 27 | + }) |
| 28 | + parseNumber(val: string): number { |
| 29 | + return Number(val); |
| 30 | + } |
| 31 | + |
| 32 | + @Option({ |
| 33 | + flags: '--not_show_stakes [boolean]', |
| 34 | + description: 'Do not display a list of steaks. Note: used_slots, uniq_users, min_stake will be filled', |
| 35 | + defaultValue: true, |
| 36 | + }) |
| 37 | + parseBoolean(val: string): boolean { |
| 38 | + return JSON.parse(val); |
| 39 | + } |
| 40 | + |
| 41 | +} |
0 commit comments