Skip to content

Commit d3569de

Browse files
committed
JSONPath support for output
1 parent d52493c commit d3569de

3 files changed

Lines changed: 29 additions & 7 deletions

File tree

package-lock.json

Lines changed: 20 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"@nestjs/core": "^11.0.1",
4444
"@nestjs/platform-express": "^11.0.1",
4545
"inquirer": "^12.5.2",
46+
"jmespath": "^0.16.0",
4647
"js-yaml": "^4.1.0",
4748
"minter-js-sdk": "^0.46.2",
4849
"minter-typescript-sdk": "^1.1.7",
@@ -60,11 +61,12 @@
6061
"@swc/cli": "^0.6.0",
6162
"@swc/core": "^1.10.7",
6263
"@types/express": "^5.0.0",
64+
"@types/inquirer": "^8.2.10",
6365
"@types/jest": "^29.5.14",
66+
"@types/jmespath": "^0.15.2",
6467
"@types/js-yaml": "^4.0.9",
6568
"@types/node": "^22.10.7",
6669
"@types/supertest": "^6.0.2",
67-
"@types/inquirer": "^8.2.10",
6870
"eslint": "^9.18.0",
6971
"eslint-config-prettier": "^10.0.1",
7072
"eslint-plugin-prettier": "^5.2.2",

src/commands/api/CandidateCommand.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import {Option, CommandRunner, SubCommand} from 'nest-commander';
22
import {MinterApiService} from '../../services/minter-api/minter-api.service';
33
import {JsonPatches} from "../../utils/JsonPatches";
44

5+
import {search} from 'jmespath'
6+
// import * as jmespath from 'jmespath'
7+
58
@SubCommand({
69
name: 'candidate',
710
arguments: '<public_key>',
@@ -28,7 +31,8 @@ export class CandidateCommand extends CommandRunner {
2831
if (options.patches) {
2932
new JsonPatches().printPropertyNames(result)
3033
} else if (options.patch && options.patch.length > 0) {
31-
out=result[options.patch]
34+
// out=result[options.patch]
35+
out=search(result,options.patch)
3236
} else {
3337
out=result
3438
}
@@ -42,8 +46,6 @@ export class CandidateCommand extends CommandRunner {
4246
return Promise.resolve(undefined);
4347
}
4448

45-
46-
4749
@Option({
4850
flags: '--height [number]',
4951
name: 'Height',
@@ -75,7 +77,7 @@ export class CandidateCommand extends CommandRunner {
7577

7678
@Option({
7779
flags: '-p, --patch [string]',
78-
description: 'path to config file',
80+
description: 'path JMESPath format',
7981
// defaultValue: 'status',
8082
})
8183
parsePatch(val: string): string {

0 commit comments

Comments
 (0)