-
Notifications
You must be signed in to change notification settings - Fork 3
/
get.ts
51 lines (48 loc) · 1.59 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { Flags } from '@oclif/core'
import { fetchVariables, fetchVariableByKey } from '../../api/variables'
import Base from '../base'
import { batchRequests } from '../../utils/batchRequests'
export default class DetailedVariables extends Base {
static hidden = false
static flags = {
...Base.flags,
keys: Flags.string({
description:
'Comma-separated list of variable keys to fetch details for',
}),
search: Flags.string({
description: 'Filter variables by search query',
}),
page: Flags.integer({
description: 'Page number to fetch',
}),
'per-page': Flags.integer({
description: 'Number of variables to fetch per page',
}),
}
authRequired = true
public async run(): Promise<void> {
const { flags } = await this.parse(DetailedVariables)
const keys = flags['keys']?.split(',')
const { project, headless } = flags
await this.requireProject(project, headless)
let variables
if (keys) {
variables = await batchRequests(keys, (key) =>
fetchVariableByKey(this.authToken, this.projectKey, key),
)
} else {
const query = {
page: flags['page'],
perPage: flags['per-page'],
search: flags['search'],
}
variables = await fetchVariables(
this.authToken,
this.projectKey,
query,
)
}
this.writer.showResults(variables)
}
}