Filter by any attribute
All checks were successful
Tests / sdk_tests (pull_request) Successful in 3m45s
All checks were successful
Tests / sdk_tests (pull_request) Successful in 3m45s
This commit is contained in:
parent
1fa32a3cc1
commit
f1e3f7b673
@ -9,9 +9,6 @@ export const command = 'list';
|
|||||||
export const desc = 'List records.';
|
export const desc = 'List records.';
|
||||||
|
|
||||||
export const builder = {
|
export const builder = {
|
||||||
'bond-id': {
|
|
||||||
type: 'string'
|
|
||||||
},
|
|
||||||
type: {
|
type: {
|
||||||
type: 'string'
|
type: 'string'
|
||||||
},
|
},
|
||||||
@ -27,7 +24,13 @@ export const builder = {
|
|||||||
export const handler = async (argv: Arguments) => {
|
export const handler = async (argv: Arguments) => {
|
||||||
const { services: { cns: cnsConfig } } = getConfig(argv.config as string)
|
const { services: { cns: cnsConfig } } = getConfig(argv.config as string)
|
||||||
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig);
|
const { restEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, cnsConfig);
|
||||||
const { type, name, bondId, all } = argv;
|
const { type, name, all } = argv;
|
||||||
|
const filters: any = {};
|
||||||
|
|
||||||
|
const filterArgs = argv._.slice(3);
|
||||||
|
for (let i = 0; i < filterArgs.length-1; i+=2) {
|
||||||
|
filters[String(filterArgs[i]).replace(/^-+/,"")] = filterArgs[i+1];
|
||||||
|
}
|
||||||
|
|
||||||
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
assert(restEndpoint, 'Invalid CNS REST endpoint.');
|
||||||
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
assert(gqlEndpoint, 'Invalid CNS GQL endpoint.');
|
||||||
@ -35,6 +38,15 @@ export const handler = async (argv: Arguments) => {
|
|||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
|
|
||||||
const result = await registry.queryRecords({ bondId, type, name }, all as boolean);
|
try {
|
||||||
queryOutput(result,argv.output)
|
const result = await registry.queryRecords({...filters, type, name}, all as boolean);
|
||||||
|
queryOutput(result, argv.output)
|
||||||
|
} catch (e) {
|
||||||
|
// https://git.vdb.to/cerc-io/laconicd/issues/118
|
||||||
|
if (Array.isArray(e) && (e as []).length && e[0].message?.includes("store doesn't have key")) {
|
||||||
|
queryOutput([], argv.output)
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,5 +6,6 @@ export const desc = 'Record operations.';
|
|||||||
|
|
||||||
exports.builder = (yargs: yargs.Argv) => {
|
exports.builder = (yargs: yargs.Argv) => {
|
||||||
return yargs.commandDir('record-cmds')
|
return yargs.commandDir('record-cmds')
|
||||||
|
.parserConfiguration({'unknown-options-as-args': true})
|
||||||
.demandCommand()
|
.demandCommand()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user