} else if (args._.length > 0) { await checkMetricsPermission() insight.trackEvent({
} else if (args._.length > 0) { await checkMetricsPermission() insight.trackEvent({
const parseArgs = processArgs => { const args = minimist(processArgs.slice(2)); return { entry: first(args._), esm: !!args.esm }; }
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 executeCmd(stdin) { if (commandName in commands) { commands[commandName]({ url: argv._[1], addOptions: argv, saveOptions: argv, mockFolderName: mockFolderName, port: port, verbose: verbose, silent: silent, stdin: stdin.trim() }); } else if (argv.version || argv.v) { commands.version(); } else { commands.help(); } }
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} **`) } } } }
async function run() { let contentTypes; if (argv._.length === 1) { contentTypes = JSON.parse(fs.readFileSync(argv._[0], 'utf8')); } else if (managementToken) { contentTypes = await convertApi .getContentTypesFromManagementApi(spaceId, managementToken, environmentId); } else if (apiToken) { contentTypes = await convertApi .getContentTypesFromDistributionApi(spaceId, apiToken, environmentId); } else { console.log(usageHelp); return false; } const options = { hideEntityFields: argv.n || argv['no-fields'], dev: argv.dev || argv.d }; const modelsMap = convertApi.contentTypesToModelMap(contentTypes); const dotStr = convertApi.modelsMapToDot(modelsMap, options); console.log(dotStr); return dotStr; }
/** * 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(' ')}` }
} else if (conf.h || conf.help) { console.error(config.helpMessage); } else if (conf._.length === 0) { console.error(config.shortHelpMessage); } else {
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(); }); }