aboutsummaryrefslogtreecommitdiffstats
path: root/apps/cli/index.ts
blob: 4d0adafb8d0c1c3d66b100e4980212370389bc42 (plain) (blame)
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
import { Command, Option } from "@commander-js/extra-typings";
import { bookmarkCmd } from "commands/bookmarks";
import { whoamiCmd } from "commands/whoami";
import { setGlobalOptions } from "lib/globals";

const program = new Command()
  .name("hoarder-cli")
  .description("A CLI interface to interact with the hoarder api")
  .addOption(
    new Option("--api-key <key>", "The API key to interact with the API")
      .makeOptionMandatory(true)
      .env("HOARDER_API_KEY"),
  )
  .addOption(
    new Option(
      "--server-addr <addr>",
      "The address of the server to connect to",
    )
      .makeOptionMandatory(true)
      .env("HOARDER_SERVER_ADDR"),
  )
  .version(process.env.SERVER_VERSION ?? "nightly");

program.addCommand(bookmarkCmd);
program.addCommand(whoamiCmd);

setGlobalOptions(program.opts());

program.parse();