Software: Apache. PHP/8.1.30 uname -a: Linux server1.tuhinhossain.com 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root) Safe-mode: OFF (not secure) /usr/share/doc/node-commander/examples/ drwxr-xr-x |
Viewing file: Select action/file-type: #!/usr/bin/env node // This is used as an example in the README for: // Custom option processing // You may specify a function to do custom processing of option values. // const commander = require('commander'); // (normal include) const commander = require('../'); // include commander in git clone of commander repo const program = new commander.Command(); function myParseInt(value, dummyPrevious) { // parseInt takes a string and a radix const parsedValue = parseInt(value, 10); if (isNaN(parsedValue)) { throw new commander.InvalidArgumentError('Not a number.'); } return parsedValue; } function increaseVerbosity(dummyValue, previous) { return previous + 1; } function collect(value, previous) { return previous.concat([value]); } function commaSeparatedList(value, dummyPrevious) { return value.split(','); } program .option('-f, --float <number>', 'float argument', parseFloat) .option('-i, --integer <number>', 'integer argument', myParseInt) .option('-v, --verbose', 'verbosity that can be increased', increaseVerbosity, 0) .option('-c, --collect <value>', 'repeatable value', collect, []) .option('-l, --list <items>', 'comma separated list', commaSeparatedList) ; program.parse(); const options = program.opts(); if (options.float !== undefined) console.log(`float: ${options.float}`); if (options.integer !== undefined) console.log(`integer: ${options.integer}`); if (options.verbose > 0) console.log(`verbosity: ${options.verbose}`); if (options.collect.length > 0) console.log(options.collect); if (options.list !== undefined) console.log(options.list); // Try the following: // node options-custom-processing -f 1e2 // node options-custom-processing --integer 2 // node options-custom-processing -v -v -v // node options-custom-processing -c a -c b -c c // node options-custom-processing --list x,y,z |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0039 ]-- |