-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
run_download.go
41 lines (34 loc) · 1.32 KB
/
run_download.go
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
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/completers/gh_completer/cmd/action"
"github.com/spf13/cobra"
)
var run_downloadCmd = &cobra.Command{
Use: "download [<run-id>]",
Short: "Download artifacts generated by a workflow run",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(run_downloadCmd).Standalone()
run_downloadCmd.Flags().StringP("dir", "D", "", "The directory to download artifacts into")
run_downloadCmd.Flags().StringSliceP("name", "n", []string{}, "Download artifacts that match any of the given names")
run_downloadCmd.Flags().StringSliceP("pattern", "p", []string{}, "Download artifacts that match a glob pattern")
runCmd.AddCommand(run_downloadCmd)
carapace.Gen(run_downloadCmd).FlagCompletion(carapace.ActionMap{
"dir": carapace.ActionDirectories(),
// TODO name
})
carapace.Gen(run_downloadCmd).FlagCompletion(carapace.ActionMap{
"dir": carapace.ActionDirectories(),
"name": carapace.ActionCallback(func(c carapace.Context) carapace.Action {
if len(c.Args) > 0 {
return action.ActionWorkflowArtifactNames(run_downloadCmd, c.Args[0])
}
return carapace.ActionValues()
}),
})
carapace.Gen(run_downloadCmd).PositionalCompletion(
action.ActionWorkflowRuns(run_downloadCmd, action.RunOpts{All: true}),
)
}