markdowny/src/cli.ts
Dylan R. E. Moonfire 9e42f79fc2 Initial commit.
2016-10-31 19:25:37 -05:00

38 lines
1.1 KiB
TypeScript

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;
}