52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import { setGlobalOptions } from "@/lib/globals";
|
|
import { Command, Option } from "@commander-js/extra-typings";
|
|
|
|
import { whoamiCmd } from "@/commands/whoami";
|
|
import { colorsCmd } from "@/commands/colors";
|
|
import { categoriesCmd } from "@/commands/categories";
|
|
import { daysCmd } from "@/commands/days";
|
|
import { hoursCmd } from "./commands/hours";
|
|
import { settingsCmd } from "./commands/settings";
|
|
|
|
import { config } from "dotenv";
|
|
|
|
config({
|
|
path: "./.env.local",
|
|
}
|
|
)
|
|
|
|
const program = new Command()
|
|
.name("lifetracker")
|
|
.description("A CLI interface to interact with my lifetracker api")
|
|
.addOption(
|
|
new Option("--api-key <key>", "the API key to interact with the API")
|
|
.makeOptionMandatory(true)
|
|
.env("LIFETRACKER_API_KEY"),
|
|
)
|
|
.addOption(
|
|
new Option(
|
|
"--server-addr <addr>",
|
|
"the address of the server to connect to",
|
|
)
|
|
.makeOptionMandatory(true)
|
|
.env("LIFETRACKER_SERVER_ADDR"),
|
|
)
|
|
.addOption(new Option("--json", "to output the result as JSON"))
|
|
.version(
|
|
import.meta.env && "CLI_VERSION" in import.meta.env
|
|
? import.meta.env.CLI_VERSION
|
|
: "0.0.0",
|
|
);
|
|
|
|
program.addCommand(whoamiCmd);
|
|
program.addCommand(daysCmd);
|
|
program.addCommand(colorsCmd);
|
|
program.addCommand(categoriesCmd);
|
|
program.addCommand(hoursCmd);
|
|
program.addCommand(settingsCmd);
|
|
|
|
|
|
setGlobalOptions(program.opts());
|
|
|
|
program.parse();
|