diff --git a/Readme.md b/Readme.md index 577a16396..7f9e110e0 100644 --- a/Readme.md +++ b/Readme.md @@ -376,18 +376,11 @@ program .version('0.1.0') .arguments(' [env]') .action(function (cmd, env) { - cmdValue = cmd; - envValue = env; + console.log('command:', cmdValue); + console.log('environment:', envValue || 'no environment given'); }); program.parse(process.argv); - -if (typeof cmdValue === 'undefined') { - console.error('no command given!'); - process.exit(1); -} -console.log('command:', cmdValue); -console.log('environment:', envValue || "no environment given"); ``` The last argument of a command can be variadic, and only the last argument. To make an argument variadic you diff --git a/examples/env b/examples/env index e6b62034a..ba91bfdc4 100755 --- a/examples/env +++ b/examples/env @@ -12,16 +12,9 @@ let envValue; program .version('0.0.1') .arguments(' [env]') - .action(function(cmd, env) { - cmdValue = cmd; - envValue = env; + .action(function(cmdValue, envValue) { + console.log('command:', cmdValue); + console.log('environment:', envValue || 'no environment given'); }); program.parse(process.argv); - -if (typeof cmdValue === 'undefined') { - console.error('no command given!'); - process.exit(1); -} -console.log('command:', cmdValue); -console.log('environment:', envValue || 'no environment given');