本文整理汇总了TypeScript中commander.Command.help方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Command.help方法的具体用法?TypeScript Command.help怎么用?TypeScript Command.help使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类commander.Command
的用法示例。
在下文中一共展示了Command.help方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: main
async function main() {
// Command-line interface.
let program = new commander.Command();
let filename: string | undefined = undefined;
program
.usage('[options] <calendar.ics>')
.option('-a, --agenda', 'print human-readable agenda')
.option('-g, --grid', 'print availability grid')
.option('-d, --date <date>', 'show data for a given day')
.option('-w, --week <date>', 'show data for a given week')
.action((fn) => {
filename = fn;
});
program.parse(process.argv);
if (!filename) {
program.help();
return;
}
let opts = program.opts();
// Parse the calendar.
let data = await read_string(filename);
let jcal = ICAL.parse(data);
// Time range.
let day: ICAL.Time;
let start: ICAL.Time;
let end: ICAL.Time;
if (opts.date) {
// Show a single day.
day = ICAL.Time.fromString(opts.date);
start = end = day;
} else {
// Show a whole week (the default).
if (opts.week) {
day = ICAL.Time.fromString(opts.week);
} else {
day = ICAL.Time.now();
}
start = day.startOfWeek();
end = day.endOfWeek();
end.adjust(1, 0, 0, 0); // "One past the end" for iteration.
}
// Get events in the range.
let instances = Array.from(get_occurrences(jcal, start, end));
// Display the data.
let dates_iter = iter_time(start, end, new ICAL.Duration({ days: 1 }));
if (opts.agenda) {
// Agenda display.
for (let date of dates_iter) {
for (let line of show_agenda(instances, date)) {
console.log(line);
}
}
} else {
// Grid display.
console.log(draw_header());
for (let date of dates_iter) {
for (let line of draw_avail(instances, date)) {
console.log(line);
}
}
}
}
示例2: main
async function main() {
let argv = process.argv;
let path = require("path");
let configDir = path.join(process.cwd(), "dist-client/config");
let gmeConfig = require(configDir);
let config = gmeConfig.config;
let MongoURI = require("mongo-uri");
let Command = require("commander").Command;
let webgme = require("webgme");
let logger = webgme.Logger.create("gme:bin:runplugin", config.bin.log);
let program = new Command();
let STORAGE_CONSTANTS = webgme.requirejs("common/storage/constants");
let PluginCliManager = webgme.PluginCliManager;
webgme.addToRequireJsPaths(config);
program
.version("2.2.0")
.arguments("<pluginName> <projectName>")
.option("-b, --branchName [string]", "Name of the branch to load and save to.", "master")
.option("-c, --commitHash [string]", "Commit hash to run from, if set branch will only be used for update.")
.option("-a, --activeNode [string]", "ID/Path to active node.", "")
.option("-s, --activeSelection [string]", "IDs/Paths of selected nodes (comma separated with no spaces).",
(val: string) => {
return val ? val.split(",") : [];
})
.option("-n, --namespace [string]",
"Namespace the plugin should run under.", "")
.option("-m, --mongo-database-uri [url]",
"URI of the MongoDB [default from the configuration file]", config.mongo.uri)
.option("-u, --user [string]", "the user of the command [if not given we use the default user]",
config.authentication.guestAccount)
.option("-o, --owner [string]", "the owner of the project [by default, the user is the owner]")
.option("-j, --pluginConfigPath [string]",
"Path to json file with plugin options that should be overwritten.", "")
.on("--help", () => {
let env = process.env.NODE_ENV || "default";
console.log(" Examples:");
console.log();
console.log(" $ node run_plugin.js PluginGenerator TestProject");
console.log(" $ node run_plugin.js PluginGenerator TestProject -b branch1 -j pluginConfig.json");
console.log(" $ node run_plugin.js MinimalWorkingExample TestProject -a /1/b");
console.log(" $ node run_plugin.js MinimalWorkingExample TestProject -s /1,/1/c,/d");
console.log(" $ node run_plugin.js MinimalWorkingExample TestProject -c #123..");
console.log(" $ node run_plugin.js MinimalWorkingExample TestProject -b b1 -c " +
"#def8861ca16237e6756ee22d27678d979bd2fcde");
console.log();
console.log(" Plugin paths using " + configDir + path.sep + "config." + env + ".js :");
console.log();
for (let path of config.plugin.basePaths) {
console.log(` "${path}"`);
}
})
.parse(argv);
if (program.args.length < 2) {
program.help();
return Promise.reject(new Error("A project and pluginName must be specified."));
}
// this line throws a TypeError for invalid databaseConnectionString
MongoURI.parse(program.mongoDatabaseUri);
config.mongo.uri = program.mongoDatabaseUri;
let pluginName = program.args[0];
let projectName = program.args[1];
logger.info(`Executing ${pluginName} plugin on ${projectName} in branch ${program.branchName}`);
let pluginConfig = {};
if (program.pluginConfigPath) {
try {
pluginConfig = require(path.resolve(program.pluginConfigPath));
} catch (e) {
return Promise.reject(e);
}
}
let gmeAuth: any = undefined;
try {
gmeAuth = await webgme.getGmeAuth(config);
} catch (_err) {
throw new Error("problem with authorization");
}
let storage = await webgme.getStorage(logger, config, gmeAuth);
await storage.openDatabase();
let params = {
projectId: "",
username: program.user
};
logger.info("Database is opened.");
if (program.owner) {
params.projectId = program.owner + STORAGE_CONSTANTS.PROJECT_ID_SEP + projectName;
} else {
params.projectId = program.user + STORAGE_CONSTANTS.PROJECT_ID_SEP + projectName;
//.........这里部分代码省略.........