-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathget-runs.ts
59 lines (49 loc) · 1.74 KB
/
get-runs.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
52
53
54
55
56
57
58
59
/*
* Copyright (C) 2018-2023 Garden Technologies, Inc. <[email protected]>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import { Command, CommandResult, CommandParams } from "../base"
import { printHeader } from "../../logger/util"
import { StringsParameter } from "../../cli/params"
import { makeGetTestOrTaskLog } from "../helpers"
import { ActionDescriptionMap } from "../../actions/base"
import { keyBy } from "lodash"
const getRunsArgs = {
names: new StringsParameter({
help: "Specify run(s)/task(s) to list. You may specify multiple names, separated by spaces.",
spread: true,
getSuggestions: ({ configDump }) => {
return Object.keys(configDump.actionConfigs.Run)
},
}),
}
type Args = typeof getRunsArgs
export class GetRunsCommand extends Command<Args, {}, ActionDescriptionMap> {
name = "runs"
help = "Lists the Runs (or tasks, if using modules) defined in your project."
aliases = ["tasks"]
// TODO-0.13.0: add output schema
arguments = getRunsArgs
printHeader({ log }) {
printHeader(log, "Runs", "📖")
}
async action({ args, garden, log }: CommandParams<Args>): Promise<CommandResult<ActionDescriptionMap>> {
const graph = await garden.getConfigGraph({ log, emit: false })
const actions = graph.getRuns({ names: args.names })
if (actions.length > 0) {
const logStr = makeGetTestOrTaskLog(actions)
log.info(logStr.trim())
} else {
log.info(`No Run actions defined for project ${garden.projectName}`)
}
return {
result: keyBy(
actions.map((t) => t.describe()),
"key"
),
}
}
}