From 3352a3ea393849550573deff8d774ba6bf149471 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Wed, 24 Apr 2024 11:37:35 +0100 Subject: build(cli): Prepare for publishing CLI to npm --- apps/cli/src/index.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 apps/cli/src/index.ts (limited to 'apps/cli/src/index.ts') diff --git a/apps/cli/src/index.ts b/apps/cli/src/index.ts new file mode 100644 index 00000000..cdb2956e --- /dev/null +++ b/apps/cli/src/index.ts @@ -0,0 +1,34 @@ +#! /usr/bin/env node +import { bookmarkCmd } from "@/commands/bookmarks"; +import { listsCmd } from "@/commands/lists"; +import { tagsCmd } from "@/commands/tags"; +import { whoamiCmd } from "@/commands/whoami"; +import { setGlobalOptions } from "@/lib/globals"; +import { Command, Option } from "@commander-js/extra-typings"; + +const program = new Command() + .name("hoarder-cli") + .description("A CLI interface to interact with the hoarder api") + .addOption( + new Option("--api-key ", "The API key to interact with the API") + .makeOptionMandatory(true) + .env("HOARDER_API_KEY"), + ) + .addOption( + new Option( + "--server-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(listsCmd); +program.addCommand(tagsCmd); +program.addCommand(whoamiCmd); + +setGlobalOptions(program.opts()); + +program.parse(); -- cgit v1.2.3-70-g09d2