Skip to content

Commit

Permalink
Add options and version to CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
maastrich committed Nov 13, 2023
1 parent 76a5af0 commit 1bcb243
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { cac } from "cac";
import { spawnSync } from "child_process";

import pkg from "../package.json";

import { exec } from "./cli/exec.js";
import { list } from "./cli/list.js";
import { help } from "./utils/help.js";
Expand All @@ -19,6 +21,15 @@ const commands = await scan();

const cli = cac("moonx");

cli.option("cache", "");
cli.option("color", "");
cli.option("concurrency", "");
cli.option("c", "");
cli.option("log", "");
cli.option("logFile", "");
cli.option("moon-help", "");
cli.option("moon-version", "");

cli
.command("_moonx_list [...params]", "List all available tasks")
.action((arg) => {
Expand Down Expand Up @@ -72,6 +83,8 @@ cli.on("command:*", () => {
process.exit(1);
});

cli.version(pkg.version);

try {
cli.parse(Bun.argv, { run: false });
await cli.runMatchedCommand();
Expand Down
4 changes: 3 additions & 1 deletion src/utils/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ ${chalk.bold("Moon option:")}
--log <LOG> Lowest log level to output [env: MOON_LOG=] [default: info] [possible values: off, error, warn, info, debug, trace]
--logFile <LOG_FILE> Path to a file to dump the moon logs [env: MOON_LOG_FILE=]
-h, --help Print help
-V, --version Print version
-v, --version Print moonx version
--moon-version Print moon version
--moon-help Print moon help
For more info, run any command with the --help flag
e.g. ${chalk.yellow("moonx <command> --help")}
Expand Down

0 comments on commit 1bcb243

Please sign in to comment.