catchify(async function (argv) { const args = minimist(argv, { alias: { help: 'h'
const parseArgs = processArgs => { const args = minimist(processArgs.slice(2)); return { entry: first(args._), esm: !!args.esm }; }
/** * ParseArgs - Parse cli arguments * * @returns {Object} action and options */ function parseArgs(): {action: string, opt?: any} { const action: string = process.argv[2] const opt: Object = minimist(process.argv, {default: {platform: 'native'}}) return {action, opt} }
minimist(search.split(' ').map(function(e) { //replaces -exact by --exact so that minimist parses them correctly if(/^-{1}[a-z]{2,}$/gi.test(e)) { e = e.replace('-', '--') } return e }), {boolean: true})
const handleFunction = argv => async (fn, name, offset = 0) => { if (isInteractive(argv) && isLast(argv, name)) { const args = introspect(fn) const values = await interactive.getFlags(args) const result = await fn(...values) return result } if (isHelp(argv) && isLast(argv, name)) { return help.functionText(fn) } // if there is a name // it means this is a subcommand so let's // shift the argv if (name) { const cmdIndex = process.argv.findIndex(item => item === name) return parseFn(minimist(process.argv.slice(cmdIndex)))(fn, offset) } return parseFn(argv)(fn, offset) }
function main() { const runtimeArgs = minimist(process.argv.slice(2)); const { repeats } = runtimeArgs; Promise.resolve(runtimeArgs._) .mapSeries((testName, i, length) => { console.log(`[${ i + 1 }/${ length }] processing: ${path.basename(testName)}`); return measure(testName, { repeats }); }) .then(results => { console.log(`\nresults for ${repeats} executions\n`); prettyPrint(results, { repeats }); printPlatform(); }); }
handle (message, PluginLoader, Scheduler) { if (this.checkIfMessageStartsWithPrefix(message)) { const input = spawnargs(message.content.slice(this.prefix.length)) const flags = minimist(input) const args = flags._ const command = args.shift() if (!command) { return false } const request = PluginLoader.getPluginCommand(command) if (request) { if (message.member.hasPermission(request.permissions)) { Scheduler.addScheduledCommand({ 'object': request.plugin, 'command': request.plugin.commands[request.command].function, 'args': { message: message, args: args, flags: flags } }) } else { message.author.send(`Sorry, but you are not allowed to run the command ** ${command} **`) } } } }
/* istanbul ignore next */ function cli () { start(minimist(process.argv.slice(2), { integer: ['port'], alias: { port: 'p', help: 'h', address: 'a', path: 'P', name: 'n' }, default: { port: 3000, host: '127.0.0.1' } })) }
/** * Returns the Usage help text for calling the cli using process.argv * * @return {string} formatted usage text * * @example * usageText() // USAGE:\n mycli * */ const usageText = () => { const cwd = process.cwd() const fullArgs = minimist(process.argv) const stats = fs.lstatSync(fullArgs._[1]) let subcommands = fullArgs._ if (stats.isSymbolicLink()) { // Probably is a better way to test if it's a linked bin // but isSymbolicLink seems to work for now. // this removes node if the second lib subcommands = subcommands.slice(1) } subcommands = subcommands.map(c => c.split('/').pop()) return `USAGE:\n\t${subcommands.join(' ')}` }
function main() { const { module, repeats } = minimist(process.argv.slice(2)); const moduleUnderTest = require(module); const result = new BenchmarkResult({
}, opts) var argv = minimist(process.argv.slice(2), { alias: { global: 'globals',
minimist( process.argv.slice(2), { alias: { h: "help", s: "split", t: "text", v: "version", }, boolean: ["help", "version"], string: ["split", "text"], unknown: (arg) => { unknowns.push(arg) }, } )
function main() { const runtimeArgs = minimist(process.argv.slice(2)); const { repeats } = runtimeArgs; Promise.resolve(runtimeArgs._) .mapSeries((testName, i, length) => { console.log(`[${ i + 1 }/${ length }] processing: ${path.basename(testName)}`); return measure(testName, { repeats }); }) .then(results => { console.log(`\nresults for ${repeats} executions\n`); prettyPrint(results, { repeats }); printPlatform(); }); }
function main() { const { module, repeats } = minimist(process.argv.slice(2)); const moduleUnderTest = require(module); const result = new BenchmarkResult({