-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod.ts
executable file
·40 lines (37 loc) · 1.35 KB
/
mod.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env -S deno run -A
import { Command, program } from "npm:commander"
import type { Command as Cmd } from "npm:comamnder"
import { name, version, description } from "./lib/constants.ts"
import { setLogLevel } from "./lib/logging.ts";
import { setupRepo } from "./commands/setup.ts";
import { dotenvxCli } from "./commands/dotenvx.ts";
import { secrets } from "./commands/secrets.ts";
program
.name(name)
.version(version)
.description(description)
.usage("[global opts] command")
.option("-l, --log-level <level>", "set log level", "info")
.option("-q, --quiet", "sets log level to error")
.option("-v, --verbose", "sets log level to verbose")
.option("-d, --debug", "sets log level to debug")
.hook("preAction", (thisCommand: Cmd, _actionCommand: Cmd) => {
const options = thisCommand.opts();
setLogLevel(options);
});
program
.command("init")
.description("setup a fresh centralized git repo for dotenvx management")
.option("-c, --copy-missing", "only copy missing files")
.option("-o, --overwrite, --override", "overwrite existing files")
.option(
"-b, --default-branch, --branch",
"default branch name for 'git init'",
"main"
)
.argument("[directory]", "directory where files will be copied")
.alias("setup")
.action(setupRepo);
program.addCommand(dotenvxCli)
program.addCommand(secrets)
program.parse()