Skip to content

Commit 80ff618

Browse files
authored
Merge pull request #18 from coderoad/fix/help
refactor help
2 parents b9bb0fa + 17bdfc0 commit 80ff618

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

src/build.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,8 @@ type BuildArgs = {
2929
async function build(args: string[]) {
3030
let options: BuildArgs;
3131

32-
if (args.length && ["--help", "-h"].includes(args[0])) {
33-
help();
34-
return;
35-
}
36-
3732
try {
38-
// default .
33+
// dir - default .
3934
const dir = args[0].match(/^-/) ? "." : args[0];
4035
// -m --markdown - default TUTORIAL.md
4136
const markdown =

src/cli.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import "./utils/logs";
22
import build from "./build";
33
import create from "./create";
4-
import help from "./help";
4+
import { help, create as createHelp, build as buildHelp } from "./help";
55

66
export async function cli(rawArgs: string[]): Promise<void> {
77
const command: string = rawArgs[2];
@@ -15,10 +15,18 @@ export async function cli(rawArgs: string[]): Promise<void> {
1515
return;
1616

1717
case "build":
18+
if (args.length && ["--help", "-h"].includes(args[0])) {
19+
buildHelp();
20+
return;
21+
}
1822
build(args);
1923
break;
2024

2125
case "create":
26+
if (args.length && ["--help", "-h"].includes(args[0])) {
27+
createHelp();
28+
return;
29+
}
2230
create(args);
2331
break;
2432

src/create.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,11 @@ type CreateArgs = {
1515
async function create(args: string[]): Promise<void> {
1616
let options: CreateArgs;
1717

18-
if (args.length && ["--help", "-h"].includes(args[0])) {
19-
help();
20-
return;
21-
}
22-
23-
// default .
18+
// dir - default .
2419
const dir = !args.length || args[0].match(/^-/) ? "." : args[0];
20+
// lang - default js
2521
const lang = getArg(args, { name: "lang", alias: "l" }) || "js";
22+
// testRunner - default mocha
2623
const testRunner =
2724
getArg(args, { name: "testRunner", alias: "t" }) || "mocha";
2825

src/help.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default function help() {
1+
export function help() {
22
console.log(`
33
Usage: coderoad [options]
44

0 commit comments

Comments
 (0)