From c3c8247d2398d35e620bbc35e638212d44514558 Mon Sep 17 00:00:00 2001 From: Ross Stenersen Date: Mon, 6 Oct 2025 09:51:41 -0500 Subject: [PATCH] fix: hide `--token` flag and be more specific with environment variable support --- src/__tests__/lib/command/smartthings-command.test.ts | 3 +-- src/lib/command/api-command.ts | 8 +++++++- src/lib/command/smartthings-command.ts | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/__tests__/lib/command/smartthings-command.test.ts b/src/__tests__/lib/command/smartthings-command.test.ts index 7798243a..ed396ff3 100644 --- a/src/__tests__/lib/command/smartthings-command.test.ts +++ b/src/__tests__/lib/command/smartthings-command.test.ts @@ -68,11 +68,10 @@ const { test('smartThingsCommandBuilder', () => { - const { envMock, optionMock, argvMock } = buildArgvMock() + const { optionMock, argvMock } = buildArgvMock() expect(smartThingsCommandBuilder(argvMock)).toBe(argvMock) - expect(envMock).toHaveBeenCalledTimes(1) expect(optionMock).toHaveBeenCalledTimes(2) }) diff --git a/src/lib/command/api-command.ts b/src/lib/command/api-command.ts index c34bfeee..607d7b53 100644 --- a/src/lib/command/api-command.ts +++ b/src/lib/command/api-command.ts @@ -29,7 +29,13 @@ export type APICommandFlags = SmartThingsCommandFlags & { export const apiCommandBuilder = (yargs: Argv): Argv => smartThingsCommandBuilder(yargs) - .option('token', { alias: 't', desc: 'the auth token to use', type: 'string' }) + .option('token', { + alias: 't', + desc: 'the auth token to use', + type: 'string', + default: process.env.SMARTTHINGS_TOKEN, + hidden: true, + }) .option('language', { desc: 'ISO language code or "NONE" to not specify a language. Defaults to the OS locale', type: 'string', diff --git a/src/lib/command/smartthings-command.ts b/src/lib/command/smartthings-command.ts index fcad926c..b73f6b5a 100644 --- a/src/lib/command/smartthings-command.ts +++ b/src/lib/command/smartthings-command.ts @@ -18,12 +18,12 @@ export type SmartThingsCommandFlags = { export const smartThingsCommandBuilder = ( yargs: Argv, ): Argv => - yargs.env('SMARTTHINGS') + yargs .option('profile', { alias: 'p', describe: 'configuration profile', type: 'string', - default: 'default', + default: process.env.SMARTTHINGS_PROFILE ?? 'default', }) // This option is temporary and will be removed when removing automatic copy // of old configuration files. (See also yargs-transition-temp.ts.)