Skip to content

help docs for commands #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add cli arg docs
Signed-off-by: shmck <[email protected]>
  • Loading branch information
ShMcK committed Jun 1, 2020
commit 36fdd61470b5c9d6c252c33f730a440a2eba2768
7 changes: 7 additions & 0 deletions src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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];
Expand Down
6 changes: 6 additions & 0 deletions src/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -14,6 +15,11 @@ type CreateArgs = {
async function create(args: string[]): Promise<void> {
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";
Expand Down
35 changes: 31 additions & 4 deletions src/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
`);
}