@kill-switch/cli 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +14 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { Command } from "commander";
|
|
14
14
|
import { KillSwitchClient } from "@kill-switch/sdk";
|
|
15
15
|
import { resolveApiKey, resolveApiUrl } from "./config.js";
|
|
16
|
+
import { outputError } from "./output.js";
|
|
16
17
|
import { registerAuthCommands } from "./commands/auth.js";
|
|
17
18
|
import { registerAccountCommands } from "./commands/accounts.js";
|
|
18
19
|
import { registerRuleCommands } from "./commands/rules.js";
|
|
@@ -45,10 +46,19 @@ program
|
|
|
45
46
|
*/
|
|
46
47
|
const createClient = () => {
|
|
47
48
|
const opts = program.opts();
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
try {
|
|
50
|
+
return new KillSwitchClient({
|
|
51
|
+
apiKey: resolveApiKey(opts.apiKey),
|
|
52
|
+
baseUrl: resolveApiUrl(opts.apiUrl),
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
// e.g. a malformed / non-https apiUrl from config/env (resolveApiUrl throws).
|
|
57
|
+
// Some commands build the client outside their try/catch, so handle it here
|
|
58
|
+
// to emit a clean error instead of a raw stack trace.
|
|
59
|
+
outputError(err instanceof Error ? err.message : String(err), opts.json);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
52
62
|
};
|
|
53
63
|
registerAuthCommands(program, createClient);
|
|
54
64
|
registerAccountCommands(program, createClient);
|