-
Notifications
You must be signed in to change notification settings - Fork 107
/
delete.ts
35 lines (26 loc) · 925 Bytes
/
delete.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
29
30
31
32
33
34
35
import { Flags } from '@oclif/core'
import { APICommand } from '@smartthings/cli-lib'
import { chooseRule, getRuleWithLocation } from '../../lib/commands/rules-util'
export default class RulesDeleteCommand extends APICommand<typeof RulesDeleteCommand.flags> {
static description = 'delete a rule' +
this.apiDocsURL('deleteRule')
static flags = {
...APICommand.flags,
location: Flags.string({
char: 'l',
description: 'a specific location to query',
helpValue: '<UUID>',
}),
}
static args = [{
name: 'id',
description: 'rule UUID',
}]
async run(): Promise<void> {
const ruleId = await chooseRule(this, 'Select a rule to delete.', this.flags.location, this.args.id)
const locationId = this.flags.location
?? (await getRuleWithLocation(this.client, ruleId, this.flags.location)).locationId
await this.client.rules.delete(ruleId, locationId)
this.log(`Rule ${ruleId} deleted.`)
}
}