cloud-config-toolkit-cli
Advanced tools
Comparing version 0.0.2 to 0.0.3
const yargs = require('yargs'); | ||
const R = require('ramda'); | ||
const { logError } = require('./commands-util/util'); | ||
const toolkit = require('./toolkit-instance'); | ||
const commandHandlers = R.mapObjIndexed(function(func) { | ||
const commandHandlersWithToolkit = R.mapObjIndexed(function(func) { | ||
return R.partial(func, [toolkit]); | ||
@@ -18,7 +20,14 @@ }, { | ||
if (typeof commands === 'object') { | ||
if (Array.isArray(commands)) { | ||
commands.forEach(function(module) { | ||
yargs.command({ | ||
...module, | ||
handler: R.partialRight(module.handler, [toolkit, commandHandlers]) | ||
async handler(argv) { | ||
try { | ||
await module.handler(argv, toolkit, commandHandlersWithToolkit); | ||
} catch (error) { | ||
logError(error); | ||
process.exit(1); | ||
} | ||
} | ||
}) | ||
@@ -25,0 +34,0 @@ .help() |
{ | ||
"name": "cloud-config-toolkit-cli", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Cloud config toolkit: command line module", | ||
@@ -5,0 +5,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22907
710