fix cmd outputs #33
@ -23,6 +23,10 @@ export const handler = async (argv: Arguments) => {
|
||||
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const result = await registry.getAccounts([address]);
|
||||
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
|
||||
if (argv.output=="json"){
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
} else {
|
||||
console.log(result)
|
||||
}
|
||||
}
|
||||
|
@ -45,4 +45,10 @@ export const handler = async (argv: Arguments) => {
|
||||
const result = await registry.commitBid({ auctionId, commitHash }, privateKey, fee);
|
||||
const revealFile = `{"reveal_file":"${revealFilePath}"}`
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2)+ JSON.stringify(JSON.parse(revealFile)) : JSON.stringify(JSON.parse(revealFile)));
|
||||
|
||||
if (argv.output=="json"){
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2)+"\n"+JSON.stringify(JSON.parse(revealFile)) : JSON.stringify(JSON.parse(revealFile)));
|
||||
} else {
|
||||
console.log(argv.verbose ? result+"\n"+revealFile:revealFile)
|
||||
}
|
||||
}
|
||||
|
@ -29,5 +29,10 @@ export const handler = async (argv: Arguments) => {
|
||||
const reveal = fs.readFileSync(path.resolve(filePath));
|
||||
const result = await registry.revealBid({ auctionId, reveal: reveal.toString('hex') }, privateKey, fee);
|
||||
const success = `{"success":${result.code==0}}`
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2): JSON.stringify(JSON.parse(success)));
|
||||
|
||||
if (argv.output=="json"){
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2) : JSON.stringify(JSON.parse(success)));
|
||||
} else {
|
||||
console.log(argv.verbose ? result : success);
|
||||
}
|
||||
}
|
||||
|
@ -21,5 +21,9 @@ export const handler = async (argv: Arguments) => {
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const result = await registry.getAuctionsByIds([id as string]);
|
||||
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
if (argv.output=="json"){
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
} else {
|
||||
console.log(result)
|
||||
}
|
||||
}
|
||||
|
@ -25,5 +25,9 @@ export const handler = async (argv: Arguments) => {
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.setAuthorityBond({ name, bondId }, privateKey, fee);
|
||||
const success = `{"success":${result.code==0}}`
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2): JSON.stringify(JSON.parse(success)));
|
||||
if (argv.output=="json"){
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2) : JSON.stringify(JSON.parse(success)));
|
||||
} else {
|
||||
console.log(argv.verbose ? result : success);
|
||||
}
|
||||
}
|
||||
|
@ -32,5 +32,9 @@ export const handler = async (argv: Arguments) => {
|
||||
const result = await registry.reserveAuthority({ name, owner }, privateKey, fee);
|
||||
|
||||
const success = `{"success":${result.code==0}}`
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2): JSON.stringify(JSON.parse(success)));
|
||||
if (argv.output=="json"){
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2) : JSON.stringify(JSON.parse(success)));
|
||||
} else {
|
||||
console.log(argv.verbose ? result : success);
|
||||
}
|
||||
}
|
||||
|
@ -21,5 +21,9 @@ export const handler = async (argv: Arguments) => {
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const result = await registry.lookupAuthorities([name], true);
|
||||
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
if (argv.output=="json"){
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
} else {
|
||||
console.log(result)
|
||||
}
|
||||
}
|
||||
|
@ -31,5 +31,9 @@ export const handler = async (argv: Arguments) => {
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.associateBond({ recordId: id, bondId }, privateKey, fee);
|
||||
const success = `{"success":${result.code==0}}`
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2): JSON.stringify(JSON.parse(success)));
|
||||
if (argv.output=="json"){
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2) : JSON.stringify(JSON.parse(success)));
|
||||
} else {
|
||||
console.log(argv.verbose ? result : success);
|
||||
}
|
||||
}
|
||||
|
@ -23,5 +23,9 @@ export const handler = async (argv: Arguments) => {
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.cancelBond({ id }, privateKey, fee);
|
||||
const success = `{"success":${result.code==0}}`
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2): JSON.stringify(JSON.parse(success)));
|
||||
if (argv.output=="json"){
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2) : JSON.stringify(JSON.parse(success)));
|
||||
} else {
|
||||
console.log(argv.verbose ? result : success);
|
||||
}
|
||||
}
|
||||
|
@ -37,5 +37,10 @@ export const handler = async (argv: Arguments) => {
|
||||
const bondId = await registry.getNextBondId(privateKey);
|
||||
const result = await registry.createBond({ denom, amount }, privateKey, fee);
|
||||
const jsonString=`{"bondId":"${bondId}"}`
|
||||
console.log(verbose ? JSON.stringify(result, undefined, 2) : JSON.stringify(JSON.parse(jsonString),null,2));
|
||||
|
||||
if (argv.output=="json"){
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2) : JSON.stringify(JSON.parse(jsonString)));
|
||||
} else {
|
||||
console.log(argv.verbose ? result : jsonString);
|
||||
}
|
||||
}
|
||||
|
@ -23,5 +23,9 @@ export const handler = async (argv: Arguments) => {
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.dissociateBond({ recordId: id }, privateKey, fee);
|
||||
const success = `{"success":${result.code==0}}`
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2): JSON.stringify(JSON.parse(success)));
|
||||
if (argv.output=="json"){
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2) : JSON.stringify(JSON.parse(success)));
|
||||
} else {
|
||||
console.log(argv.verbose ? result : success);
|
||||
}
|
||||
}
|
||||
|
@ -21,5 +21,10 @@ export const handler = async (argv: Arguments) => {
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
|
||||
const result = await registry.getBondsByIds([id as string]);
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
|
||||
if (argv.output=="json"){
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
} else {
|
||||
console.log(result)
|
||||
}
|
||||
}
|
||||
|
@ -25,5 +25,10 @@ export const handler = async (argv: Arguments) => {
|
||||
|
||||
const { owner } = argv;
|
||||
const result = await registry.queryBonds({ owner });
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
|
||||
if (argv.output=="json"){
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
} else {
|
||||
console.log(result)
|
||||
}
|
||||
}
|
||||
|
@ -29,5 +29,9 @@ export const handler = async (argv: Arguments) => {
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.dissociateRecords({ bondId }, privateKey, fee);
|
||||
const success = `{"success":${result.code==0}}`
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2): JSON.stringify(JSON.parse(success)));
|
||||
if (argv.output=="json"){
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2) : JSON.stringify(JSON.parse(success)));
|
||||
} else {
|
||||
console.log(argv.verbose ? result : success);
|
||||
}
|
||||
}
|
||||
|
@ -34,5 +34,9 @@ export const handler = async (argv: Arguments) => {
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.reassociateRecords({ oldBondId, newBondId }, privateKey, fee);
|
||||
const success = `{"success":${result.code==0}}`
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2): JSON.stringify(JSON.parse(success)));
|
||||
if (argv.output=="json"){
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2) : JSON.stringify(JSON.parse(success)));
|
||||
} else {
|
||||
console.log(argv.verbose ? result : success);
|
||||
}
|
||||
}
|
||||
|
@ -38,5 +38,9 @@ export const handler = async (argv: Arguments) => {
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.refillBond({ id, denom, amount }, privateKey, fee);
|
||||
const success = `{"success":${result.code==0}}`
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2): JSON.stringify(JSON.parse(success)));
|
||||
if (argv.output=="json"){
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2) : JSON.stringify(JSON.parse(success)));
|
||||
} else {
|
||||
console.log(argv.verbose ? result : success);
|
||||
}
|
||||
}
|
||||
|
@ -37,5 +37,9 @@ export const handler = async (argv: Arguments) => {
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.withdrawBond({ id, denom, amount }, privateKey, fee);
|
||||
const success = `{"success":${result.code==0}}`
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2): JSON.stringify(JSON.parse(success)));
|
||||
if (argv.output=="json"){
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2) : JSON.stringify(JSON.parse(success)));
|
||||
} else {
|
||||
console.log(argv.verbose ? result : success);
|
||||
}
|
||||
}
|
||||
|
@ -24,5 +24,9 @@ export const handler = async (argv: Arguments) => {
|
||||
const result = await registry.deleteName({ crn: name }, privateKey, fee);
|
||||
|
||||
const success = `{"success":${result.code==0}}`
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2): JSON.stringify(JSON.parse(success)));
|
||||
if (argv.output=="json"){
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2) : JSON.stringify(JSON.parse(success)));
|
||||
} else {
|
||||
console.log(argv.verbose ? result : success);
|
||||
}
|
||||
}
|
||||
|
@ -27,5 +27,9 @@ export const handler = async (argv: Arguments) => {
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const result = await registry.lookupNames([name], argv.history as boolean);
|
||||
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
if (argv.output=="json"){
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
} else {
|
||||
console.log(result)
|
||||
}
|
||||
}
|
||||
|
@ -22,5 +22,9 @@ export const handler = async (argv: Arguments) => {
|
||||
|
||||
const result = await registry.resolveNames([name]);
|
||||
const success = `{"success":${result.code==0}}`
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2): JSON.stringify(JSON.parse(success)));
|
||||
if (argv.output=="json"){
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2) : JSON.stringify(JSON.parse(success)));
|
||||
} else {
|
||||
console.log(argv.verbose ? result : success);
|
||||
}
|
||||
}
|
||||
|
@ -26,5 +26,9 @@ export const handler = async (argv: Arguments) => {
|
||||
const result = await registry.setName({ crn: name, cid: id }, privateKey, fee);
|
||||
|
||||
const success = `{"success":${result.code==0}}`
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2): JSON.stringify(JSON.parse(success)));
|
||||
if (argv.output=="json"){
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2) : JSON.stringify(JSON.parse(success)));
|
||||
} else {
|
||||
console.log(argv.verbose ? result : success);
|
||||
}
|
||||
}
|
||||
|
@ -21,5 +21,9 @@ export const handler = async (argv: Arguments) => {
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
const result = await registry.getRecordsByIds([id as string]);
|
||||
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
if (argv.output=="json"){
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
} else {
|
||||
console.log(result)
|
||||
}
|
||||
}
|
||||
|
@ -36,5 +36,9 @@ export const handler = async (argv: Arguments) => {
|
||||
const registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
|
||||
const result = await registry.queryRecords({ bondId, type, name }, all as boolean);
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
if (argv.output=="json"){
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
} else {
|
||||
console.log(result)
|
||||
}
|
||||
}
|
||||
|
@ -40,5 +40,9 @@ export const handler = async (argv: Arguments) => {
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
const result = await registry.setRecord({ privateKey: userKey, record, bondId }, txKey as string, fee);
|
||||
|
||||
console.log(verbose ? JSON.stringify(result, undefined, 2) : JSON.stringify(result.data,undefined,2));
|
||||
if (argv.output=="json"){
|
||||
console.log(argv.verbose ? JSON.stringify(result, undefined, 2) : JSON.stringify(result.data,undefined,2));
|
||||
} else {
|
||||
console.log(argv.verbose ? result : result.data);
|
||||
}
|
||||
}
|
||||
|
@ -40,5 +40,9 @@ export const handler = async (argv: Arguments) => {
|
||||
const fee = getGasAndFees(argv, cnsConfig);
|
||||
await registry.sendCoins({ denom, amount, destinationAddress }, privateKey, fee);
|
||||
const result = await registry.getAccounts([fromAddress, destinationAddress]);
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
if (argv.output=="json"){
|
||||
console.log(JSON.stringify(result, undefined, 2));
|
||||
} else {
|
||||
console.log(result)
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,11 @@ yargs(hideBin(process.argv))
|
||||
default: 'config.yml',
|
||||
describe: 'Config file path.',
|
||||
type: 'string'
|
||||
},
|
||||
output: {
|
||||
alias: 'o',
|
||||
describe: 'Gives output in json format when specified.',
|
||||
type: 'string'
|
||||
}
|
||||
})
|
||||
.commandDir('cmds')
|
||||
|
Loading…
Reference in New Issue
Block a user