function runProgram() { program.parse(process.argv); if (!program.args.length) program.help(); }
Promise.all(expandGlobArgs(program.args).map(resource => isUrl(resource) ? processUrl(resource) : processFile(resource) )).then(() => { exit(process.exitCode); }).catch((e) => { console.error(chalk.red(e)); exit(process.exitCode); });
http.request(options, function (res) { res.setEncoding('utf8'); res.on('data', function (data) { console.log(program.args[0] + ' 的翻译结果为:'); console.log(JSON.parse(data).trans_result[0].dst); console.log('=== 🍻 翻译成功 🍻 ===') }); })
// send the toot from the command-line argument app.toot(config, args.args[0], args.visibility).then(function() { process.exit(0); });
const use_cached_cookie = async (username, password) => { const data = load_cached_cookie_file(); const course_url = commander.args[0]; const account_index = data.findIndex(account => account.username === username.toLowerCase()); if (account_index === -1) { const auth_headers = await login_with_username_password(username, password); find_owned_course(extract_course_name(course_url), auth_headers); } else { process.stdout.write(`\n${green_bg('Using cached cookie')}`); commander.username = username; commander.password = password; const auth_headers = login_with_cookie(undefined, data[account_index].access_token); find_owned_course(extract_course_name(course_url), auth_headers); } }
program .on('command:*', function() { console.error(('Invalid command ' + program.args[0]).red); program.outputHelp(); });
// // // function sampleMain(tjs, options) { var speed = program.args[0]; if (!speed) { program.help(); } tjs.speedLimitSetLimit(options, speed, function (err, result) { if (result.result) { var str = (speed + " MPH").green; console.log("\nSpeed limit successfully set to: " + str); } else { console.log(result.reason.red); } }); }
async function main() { if (program.args.length === 0) { program.outputHelp(); process.exit(1); } let template = Handlebars.compile(templateData); let result = await templateXmlFiles(template, program.args); if (program.output) { fs.writeFileSync(program.output, result); } else { console.log(result); } return 0; }
exec("pwd", function(err, out, stderr) { createModule(out.replace(/\r?\n|\r/g, ""), program.args[1].replace(/\r?\n|\r/g, "")); });
function main () { command .version( packageInfo.version ) .arguments( '<wiki-page-URL>' ) .description( 'Dumps a ZIM file' ) .option( '-h -help' ) .parse( process.argv ) log( command.opts() ) srcPath = expandHomeDir( command.args[0] ) outPath = expandHomeDir( command.args[1] ) if (! outPath ) { var parsed = osPath.parse(srcPath) outPath = parsed.name } core() }
commander.args.find(el => el.startsWith("http"))
Promise.resolve() .then(() => { if (!program.args[0] || !program.args[1]) { throw new Error("Invalid key/value"); } return { [program.args[0]]: program.args[1] }; }) .then(entries => { config.set(entries); }) .catch(error => { ["EACCES", "ENOENT"].includes(error.code) ? console.error("Inaccessible or inexistent configuration file") : console.error(error.message); process.exit(1); });
commander.args.find(el => el.endsWith(".css"))
commander.args.find(el => el.endsWith(".json"))
function main () { command .version( packageInfo.version ) .arguments( '<wiki-page-URL>' ) .description( 'Dumps a ZIM file' ) .option( '-h -help' ) .parse( process.argv ) log( command.opts() ) srcPath = expandHomeDir( command.args[0] ) outPath = expandHomeDir( command.args[1] ) if (! outPath ) { var parsed = osPath.parse(srcPath) outPath = parsed.name } core() }