markdowny/src/cli.ts

38 lines
1.1 KiB
TypeScript
Raw Normal View History

2016-11-01 00:25:37 +00:00
import * as yargs from "yargs";
import * as count from "./count";
import * as sections from "./sections";
import * as table from "./table";
import * as version from "./version";
// Combine everything together to create a composite arguments which is used
// to parse the input and create the usage if required.
var argv = yargs
.usage("mfgames-writing-format command")
.help("help")
.showHelpOnFail(true, "Specify --help for available options")
.demand(1)
.command("count", count.help, count.args)
.command("sections", sections.help, sections.args)
.command("table", table.help, table.args)
.command("version", version.help, version.args)
.argv;
// Use the first command to determine what we are going to do.
switch (argv._[0]) {
case "count":
count.run(argv);
break;
case "sections":
sections.run(argv);
break;
case "table":
table.run(argv);
break;
case "version":
version.run(argv);
break;
default:
console.error(`Unknown command: ${argv._[0]}`);
break;
}