-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdisable.ts
45 lines (36 loc) · 1.3 KB
/
disable.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
36
37
38
39
40
41
42
43
44
45
import {Args, Flags} from '@oclif/core'
import Command from '../../base-command'
import {toggleHostExposureEntries} from '../../modem/host-exposure'
export default class DisableHostExposureEntries extends Command {
static description = 'Disable a set of host exposure entries'
static examples = [`$ vodafone-station-cli host-exposure:disable -p PASSWORD [ENTRY NAME | [ENTRY NAME...]]`]
static args = {
entries: Args.string({
description: 'Host exposure entries to disable. Pass no names to disable every existing entry.',
required: false,
}),
}
static flags = {
password: Flags.string({
char: 'p',
description: 'router/modem password',
}),
}
static strict = false
async run(): Promise<void> {
const {argv, flags} = await this.parse(DisableHostExposureEntries)
const password = flags.password ?? process.env.VODAFONE_ROUTER_PASSWORD
if (!password || password === '') {
this.log(
'You must provide a password either using -p or by setting the environment variable VODAFONE_ROUTER_PASSWORD',
)
this.exit()
}
try {
await toggleHostExposureEntries(false, argv as string[], password!, this.logger)
} catch (error) {
this.error(error as Error, {message: 'Something went wrong.'})
}
this.exit()
}
}