-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
I am implementing pass parameters by json file allowing users to provide -i and path to a json file which has options and their values. I have 10 sub-commands and I want this parameters from json file to be passed to sub-command file to be utilised.
I have currently achieved this by putting content of input file in process.env.inputFIle and within each sub-command file I unpack this var and shove it inside process.argv
funApp.js
program.version('2.1')
.command('add' [parameters], ' adding stuff')
.command('update' [parameters], ' update stuff')
.command('remove' [parameters], ' remove stuff')
[... etc]
.option('-i, --input <value>',' json param file')
[...]
program.on('option:input', function(inputFile) {
const fileData = JSON.parse(fs.readFileSync(inputFile,'utf8'))
// Somehow pass these args to the funApp-add.js as args?!
})
That way my CLI could be funApp add -i params.json --overrideArg value --newArg value
Metadata
Metadata
Assignees
Labels
No labels