Skip to content

Commit 36fdd61

Browse files
committed
add cli arg docs
Signed-off-by: shmck <[email protected]>
1 parent 60367b2 commit 36fdd61

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed

src/build.ts

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { parse } from "./utils/parse";
77
import { getArg } from "./utils/args";
88
import { getCommits, CommitLogObject } from "./utils/commits";
99
import { validateSchema } from "./utils/validate";
10+
import { build as help } from "./help";
1011
import * as T from "../typings/tutorial";
1112

1213
const write = util.promisify(fs.writeFile);
@@ -27,6 +28,12 @@ type BuildArgs = {
2728

2829
async function build(args: string[]) {
2930
let options: BuildArgs;
31+
32+
if (args.length && ["--help", "-h"].includes(args[0])) {
33+
help();
34+
return;
35+
}
36+
3037
try {
3138
// default .
3239
const dir = args[0].match(/^-/) ? "." : args[0];

src/create.ts

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import ncp from "ncp";
22
import * as path from "path";
33
import { promisify } from "util";
44
import { getArg } from "./utils/args";
5+
import { create as help } from "./help";
56

67
const copy = promisify(ncp);
78

@@ -14,6 +15,11 @@ type CreateArgs = {
1415
async function create(args: string[]): Promise<void> {
1516
let options: CreateArgs;
1617

18+
if (args.length && ["--help", "-h"].includes(args[0])) {
19+
help();
20+
return;
21+
}
22+
1723
// default .
1824
const dir = !args.length || args[0].match(/^-/) ? "." : args[0];
1925
const lang = getArg(args, { name: "lang", alias: "l" }) || "js";

src/help.ts

+31-4
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,38 @@ export default function help() {
33
Usage: coderoad [options]
44
55
Options:
6-
help display these help docs
7-
version show coderoad cli version
8-
create start a new tutorial from a template
9-
build generate a coderoad.json file from markdown and yaml
6+
--help (-h) display these help docs
7+
--version (-v) show coderoad cli version
8+
create start a new tutorial from a template
9+
build generate a coderoad.json file from markdown and yaml
1010
1111
More docs at https://github.com/coderoad/coderoad-cli
1212
`);
1313
}
14+
15+
export function create() {
16+
console.log(`
17+
Usage: coderoad create [path] [options]
18+
19+
Options:
20+
--help (-h) display these help docs
21+
--lang (-l) programming language for template
22+
--testRunner (-t) test runner module for template
23+
24+
More docs at https://github.com/coderoad/coderoad-cli
25+
`);
26+
}
27+
28+
export function build() {
29+
console.log(`
30+
Usage: coderoad build [path] [options]
31+
32+
Options:
33+
--help (-h) display these help docs
34+
--markdown (-m) custom path to the tutorial markdown file (TUTORIAL.md)
35+
--yaml (-y) custom path to the tutorial yaml file (coderoad.yaml)
36+
--output (-o) custom path to tutorial json config file (coderoad.json)
37+
38+
More docs at https://github.com/coderoad/coderoad-cli
39+
`);
40+
}

0 commit comments

Comments
 (0)