Skip to content

Commit c3c8247

Browse files
committed
fix: hide --token flag and be more specific with environment variable support
1 parent 641dfc4 commit c3c8247

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

‎src/__tests__/lib/command/smartthings-command.test.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,10 @@ const {
6868

6969

7070
test('smartThingsCommandBuilder', () => {
71-
const { envMock, optionMock, argvMock } = buildArgvMock<object, SmartThingsCommandFlags>()
71+
const { optionMock, argvMock } = buildArgvMock<object, SmartThingsCommandFlags>()
7272

7373
expect(smartThingsCommandBuilder(argvMock)).toBe(argvMock)
7474

75-
expect(envMock).toHaveBeenCalledTimes(1)
7675
expect(optionMock).toHaveBeenCalledTimes(2)
7776
})
7877

‎src/lib/command/api-command.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ export type APICommandFlags = SmartThingsCommandFlags & {
2929

3030
export const apiCommandBuilder = <T extends object>(yargs: Argv<T>): Argv<T & APICommandFlags> =>
3131
smartThingsCommandBuilder(yargs)
32-
.option('token', { alias: 't', desc: 'the auth token to use', type: 'string' })
32+
.option('token', {
33+
alias: 't',
34+
desc: 'the auth token to use',
35+
type: 'string',
36+
default: process.env.SMARTTHINGS_TOKEN,
37+
hidden: true,
38+
})
3339
.option('language', {
3440
desc: 'ISO language code or "NONE" to not specify a language. Defaults to the OS locale',
3541
type: 'string',

‎src/lib/command/smartthings-command.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ export type SmartThingsCommandFlags = {
1818
export const smartThingsCommandBuilder = <T extends object = object>(
1919
yargs: Argv<T>,
2020
): Argv<T & SmartThingsCommandFlags> =>
21-
yargs.env('SMARTTHINGS')
21+
yargs
2222
.option('profile', {
2323
alias: 'p',
2424
describe: 'configuration profile',
2525
type: 'string',
26-
default: 'default',
26+
default: process.env.SMARTTHINGS_PROFILE ?? 'default',
2727
})
2828
// This option is temporary and will be removed when removing automatic copy
2929
// of old configuration files. (See also yargs-transition-temp.ts.)

0 commit comments

Comments
 (0)