Skip to content

Commit

Permalink
quotation app commands
Browse files Browse the repository at this point in the history
  • Loading branch information
MorenaBarboni committed Jan 18, 2024
1 parent 6047077 commit 7a5c47a
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 2 deletions.
53 changes: 53 additions & 0 deletions application/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env node
const yargs = require('yargs')
const index = require('./index.js')

yargs
.usage('$0 <cmd> [args]')
.command('submit <organization> <channel> <chaincode> <transactionName> [transactionParams..]', 'Submit a transaction', (yargs) => {
yargs
.positional('organization', {
type: 'string',
describe: 'name of the organization',
example: 'agency.quotation.com'
})
.positional('channel', {
type: 'string',
describe: 'name of the channel',
example: 'q1channel'
})
.positional('chaincode', {
type: 'string',
describe: 'name of the chaincode',
example: 'quotation'
})
.positional('transactionName', {
type: 'string',
describe: 'name of the transaction',
example: 'requestQuotation'
})
.positional('transactionParams', {
type: 'string',
describe: 'transaction parameters',
example: 'quotation1 laptop 500'
})
}, (argv) => {
index.submit(
argv.organization,
argv.channel,
argv.chaincode,
argv.transactionName,
argv.transactionParams);
})
.help()
.alias('h', 'help')
.demandCommand(1, 'You must specify a command.')
.strict()
.example('$0 submit agency.quotation.com q1channel quotation requestQuotation quotation1 laptop 500')
.fail((msg, err, yargs) => {
if (msg) console.error(msg);
if (err) console.error(err);
yargs.showHelp();
process.exit(1);
})
.argv;
19 changes: 18 additions & 1 deletion application/index.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,21 @@ async function submitT(organization, channel, chaincode, transactionName, transa

}

module.exports = { submitT }
function submit(organization, channel, chaincode, transactionName, transactionParams) {
if (!organization) {
console.log("organization argument missing!")
}
else if (!channel) {
console.log("channel argument missing!")
}
else if (!chaincode) {
console.log("chaincode argument missing!")
}
else if (!transactionName) {
console.log("transactionName argument missing!")
} else {
submitT(organization, channel, chaincode, transactionName, transactionParams)
}
}

module.exports = { submitT, submit }
3 changes: 2 additions & 1 deletion application/package.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@hyperledger/fabric-gateway": "^1.4.0",
"crypto": "^1.0.1",
"express": "^4.17.1",
"js-yaml": "^3.14.0"
"js-yaml": "^3.14.0",
"yargs": "17.7.2"
}
}

0 comments on commit 7a5c47a

Please sign in to comment.