-
Notifications
You must be signed in to change notification settings - Fork 102
/
reset.ts
28 lines (22 loc) · 1.01 KB
/
reset.ts
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
import { CliUx } from '@oclif/core'
import inquirer from 'inquirer'
import { resetManagedConfig, SmartThingsCommand } from '@smartthings/cli-lib'
export default class ConfigResetCommand extends SmartThingsCommand<typeof ConfigResetCommand.flags> {
static description = 'clear saved answers to questions\n' +
'The CLI will occasionally ask you if you want it to remember the answer to a question, such as ' +
'"Which hub do you want to use?" You can use this command to clear those answers.'
static flags = SmartThingsCommand.flags
async run(): Promise<void> {
const confirmed: boolean = (await inquirer.prompt({
type: 'confirm',
name: 'confirmed',
message: `Are you sure you want to clear saved answers to questions${this.profileName === 'default' ? '' : ` for the profile ${this.profileName}`}?`,
})).confirmed
if (confirmed) {
await resetManagedConfig(this.cliConfig, this.profileName)
CliUx.ux.log('Configuration has been reset.')
} else {
CliUx.ux.log('Configuration reset canceled.')
}
}
}