diff --git a/src/build.ts b/src/build.ts index fc341d2..29cc8ce 100644 --- a/src/build.ts +++ b/src/build.ts @@ -7,6 +7,7 @@ import { parse } from "./utils/parse"; import { getArg } from "./utils/args"; import { getCommits, CommitLogObject } from "./utils/commits"; import { validateSchema } from "./utils/validate"; +import { build as help } from "./help"; import * as T from "../typings/tutorial"; const write = util.promisify(fs.writeFile); @@ -27,6 +28,12 @@ type BuildArgs = { async function build(args: string[]) { let options: BuildArgs; + + if (args.length && ["--help", "-h"].includes(args[0])) { + help(); + return; + } + try { // default . const dir = args[0].match(/^-/) ? "." : args[0]; diff --git a/src/create.ts b/src/create.ts index 5840b10..ecb91a6 100644 --- a/src/create.ts +++ b/src/create.ts @@ -2,6 +2,7 @@ import ncp from "ncp"; import * as path from "path"; import { promisify } from "util"; import { getArg } from "./utils/args"; +import { create as help } from "./help"; const copy = promisify(ncp); @@ -14,6 +15,11 @@ type CreateArgs = { async function create(args: string[]): Promise { let options: CreateArgs; + if (args.length && ["--help", "-h"].includes(args[0])) { + help(); + return; + } + // default . const dir = !args.length || args[0].match(/^-/) ? "." : args[0]; const lang = getArg(args, { name: "lang", alias: "l" }) || "js"; diff --git a/src/help.ts b/src/help.ts index ed20f2c..9b74510 100644 --- a/src/help.ts +++ b/src/help.ts @@ -3,11 +3,38 @@ export default function help() { Usage: coderoad [options] Options: - help display these help docs - version show coderoad cli version - create start a new tutorial from a template - build generate a coderoad.json file from markdown and yaml +--help (-h) display these help docs +--version (-v) show coderoad cli version +create start a new tutorial from a template +build generate a coderoad.json file from markdown and yaml More docs at https://github.com/coderoad/coderoad-cli `); } + +export function create() { + console.log(` +Usage: coderoad create [path] [options] + +Options: +--help (-h) display these help docs +--lang (-l) programming language for template +--testRunner (-t) test runner module for template + +More docs at https://github.com/coderoad/coderoad-cli +`); +} + +export function build() { + console.log(` +Usage: coderoad build [path] [options] + +Options: +--help (-h) display these help docs +--markdown (-m) custom path to the tutorial markdown file (TUTORIAL.md) +--yaml (-y) custom path to the tutorial yaml file (coderoad.yaml) +--output (-o) custom path to tutorial json config file (coderoad.json) + +More docs at https://github.com/coderoad/coderoad-cli +`); +}