Skip to content

refactor help #18

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
refactor help
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
  • Loading branch information
ShMcK committed Jun 1, 2020
commit 17bdfc093edb4a6f8b389ce490fb26ee06a0cb19
7 changes: 1 addition & 6 deletions src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,8 @@ type BuildArgs = {
async function build(args: string[]) {
let options: BuildArgs;

if (args.length && ["--help", "-h"].includes(args[0])) {
help();
return;
}

try {
// default .
// dir - default .
const dir = args[0].match(/^-/) ? "." : args[0];
// -m --markdown - default TUTORIAL.md
const markdown =
Expand Down
10 changes: 9 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "./utils/logs";
import build from "./build";
import create from "./create";
import help from "./help";
import { help, create as createHelp, build as buildHelp } from "./help";

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

case "build":
if (args.length && ["--help", "-h"].includes(args[0])) {
buildHelp();
return;
}
build(args);
break;

case "create":
if (args.length && ["--help", "-h"].includes(args[0])) {
createHelp();
return;
}
create(args);
break;

Expand Down
9 changes: 3 additions & 6 deletions src/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +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 .
// dir - default .
const dir = !args.length || args[0].match(/^-/) ? "." : args[0];
// lang - default js
const lang = getArg(args, { name: "lang", alias: "l" }) || "js";
// testRunner - default mocha
const testRunner =
getArg(args, { name: "testRunner", alias: "t" }) || "mocha";

Expand Down
2 changes: 1 addition & 1 deletion src/help.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function help() {
export function help() {
console.log(`
Usage: coderoad [options]

Expand Down