/
get.ts
36 lines (30 loc) · 923 Bytes
/
get.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
import AppConfig from '../../app-config/config';
import BaseCommand from '../../base-command';
import InvalidConfigOption from '../../common/errors/invalid-config-option';
export default class ConfigGet extends BaseCommand {
async auth_required(): Promise<boolean> {
return false;
}
static description = 'Get the value of a CLI config option';
static examples = [
'architect config:get log_level',
];
static flags = {
...BaseCommand.flags,
};
static args = [{
name: 'option',
required: true,
description: 'Name of a config option',
}];
async run(): Promise<void> {
const { args } = await this.parse(ConfigGet);
if (!Object.keys(this.app.config).includes(args.option)) {
throw new InvalidConfigOption(args.option);
}
const value = this.app.config[args.option as keyof AppConfig];
if (typeof value === 'string') {
this.log(value);
}
}
}