-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathenable.ts
45 lines (36 loc) · 1.29 KB
/
enable.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 EnableHostExposureEntries extends Command {
static description = 'Enable a set of host exposure entries'
static examples = [`$ vodafone-station-cli host-exposure:enable -p PASSWORD [ENTRY NAME | [ENTRY NAME...]]`]
static args = {
entries: Args.string({
description: 'Host exposure entries to enable. Pass no names to enable 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(EnableHostExposureEntries)
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(true, argv as string[], password!, this.logger)
} catch (error) {
this.error(error as Error, {message: 'Something went wrong.'})
}
this.exit()
}
}