Getting the value from command line input, command-line-args NPM module, node.js/javascript -
i use code add -find flag, can't find how value in useable variable.
const commandlineargs = require('command-line-args') const quicksearch = [ {name: 'find', alias: 'f',type: string} ]
i'd achieve in terminal, -find=github, use value of find flag, in useable variable, can emit server, i've read docs theres nothing it.
run @ command-promt/bash like:
node test.js -f github
or
node test.js --find github
or
node test.js --find=github
expect output:
{ find: 'github' }
server/javascript file (test.js):
var commandlineargs = require('command-line-args') const optiondefinitions = [ { name: 'find', alias: 'f', type: string } ] const options = commandlineargs(optiondefinitions) console.log(options); //options.find equal 'github'
Comments
Post a Comment