program .arguments("<command>") .action((command) => { console.log(`Command ${command} not found\n`); program.outputHelp(); suggestCommands(command); });
// Validates any random command fired in program.arguments('<command>').action(cmd => { program.outputHelp(); console.log(` ` + chalk.red(`\n Unknown command ${chalk.yellow(cmd)}.`)); console.log(); suggestCommands(cmd); });
program.arguments('<file>').action(function (file) { var xmlParser = new xml2js.Parser(); function setupDict() { return new Promise(function (resolve, reject) { fs.readFile(file, function (err, rawData) { if (err) { log(err); process.exit(1); } var data = escape(rawData.toString(), XML_IGNORE); xmlParser.parseString(data, function (parseError, obj) { if (parseError) reject(parseError);else resolve(obj.JMdict.entry); }); }); }); } var outputFilename = "".concat(file, ".json"); setupDict().then(function (dictionary) { fs.writeFileSync(outputFilename, JSON.stringify(dictionary), 'utf8'); }); });
.version(manifest.version) .description(manifest.description) .arguments("<source-files...>") .option("-b, --bundle", "Create a non-minified bundle (*.js) for each source file") .option("-m, --minify", "Create a minified bundle (*.min.js) for each source file")
program .arguments('<command>') .action((cmd) => { program.outputHelp() console.log() console.log(` ` + chalk.red(`Unknown command ${chalk.yellow(cmd)}.`)) console.log() })
program .arguments('<level>') .option('-k, --key <private-key>', 'a private key to sign token with') .option('-f, --keyfile <private-key-file>', 'a path to a file containing the private key')
function main() { program .arguments('<file1> [file2]') .option('-u, --username <username>', 'The user to authenticate as') .option('-p, --password <password>', 'The user\'s password')
program .arguments('<file>') .action((file) => { const xmlParser = new xml2js.Parser(); function setupDict() { return new Promise((resolve, reject) => { fs.readFile(file, (err, rawData) => { if (err) { log(err); process.exit(1); } const data = escape(rawData.toString(), XML_IGNORE); xmlParser.parseString(data, (parseError, obj) => { if (parseError) reject(parseError); else resolve(obj.JMdict.entry); }); }); }); } const outputFilename = `${file}.json`; setupDict().then((dictionary) => { fs.writeFileSync(outputFilename, JSON.stringify(dictionary), 'utf8'); }); });
// output help information on unknown commands program .arguments('<command>') .action((cmd) => { program.outputHelp() console.log(` ` + chalk.red(`Unknown command ${chalk.yellow(cmd)}.`)) console.log() })