-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathupdate.ts
More file actions
61 lines (55 loc) · 1.87 KB
/
Copy pathupdate.ts
File metadata and controls
61 lines (55 loc) · 1.87 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import inquirer from '../../ui/autocomplete'
import { updateVariable } from '../../api/variables'
import {
VariablePromptResult,
descriptionPrompt,
namePrompt,
variablePrompt,
} from '../../ui/prompts'
import { Flags } from '@oclif/core'
import { UpdateVariableDto } from '../../api/schemas'
import UpdateCommandWithCommonProperties from '../updateCommandWithCommonProperties'
export default class UpdateVariable extends UpdateCommandWithCommonProperties {
static hidden = false
static description = 'Update a Variable.'
prompts = [namePrompt, descriptionPrompt]
static flags = {
...UpdateCommandWithCommonProperties.flags,
description: Flags.string({
description: 'Description for the variable',
}),
}
public async run(): Promise<void> {
const { args, flags } = await this.parse(UpdateVariable)
const { key } = args
const { headless, project } = flags
await this.requireProject(project, headless)
let variableKey = key
if (headless && !variableKey) {
this.writer.showError('The key argument is required')
return
} else if (!variableKey) {
const { variable } = await inquirer.prompt<VariablePromptResult>(
[variablePrompt],
{
token: this.authToken,
projectKey: this.projectKey,
},
)
variableKey = variable.key
this.writer.printCurrentValues(variable)
}
const params = await this.populateParametersWithZod(
UpdateVariableDto,
this.prompts,
flags,
)
const result = await updateVariable(
this.authToken,
this.projectKey,
variableKey,
params,
)
this.writer.showResults(result)
}
}