I'm working with yargs to pass arguments in a gulp command. I am having troubles checking the validity of the arguments and what shall happen if the flag is present or not.
More specifically, here is my gulpfile.js
:
'use strict';
var argv = require('yargs').options({
'config': {
alias: 'c',
demandOption: true,
default: 'default',
describe: 'Choose a configuration file name',
type: 'string'
},
'host': {
alias: 'h',
demandOption: false,
default: '',
describe: 'Replace the host starting with http://',
type: 'string'
}
}).argv;
gulp.task('config', function(){
// If argument -c is passed copy config file in path
// configs/Config_{{argv.c}}.js into Config.js
gulp.src('./app/jsx/constants/Config_' + argv.c + '.js')
.pipe(rename({ basename: 'Config'}))
.pipe(gulp.dest('./app/jsx/constants'))
})
If I gulp config -c something
, everything works as expected.
What I would like to have is : having the CLI asking for a config argument if not provided in the command.
Has anyone had experience with that?