本文整理汇总了TypeScript中commander.Command.opts方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Command.opts方法的具体用法?TypeScript Command.opts怎么用?TypeScript Command.opts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类commander.Command
的用法示例。
在下文中一共展示了Command.opts方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
}
}