From 54456e8c6768b710460d52225676dd622a0e5d6c Mon Sep 17 00:00:00 2001 From: rsteube Date: Fri, 31 May 2024 19:43:57 +0200 Subject: [PATCH] gh: updates from v2.50.0 --- .../gh_completer/cmd/action/pullrequest.go | 14 +++++++++ completers/gh_completer/cmd/pr_checks.go | 7 +++++ .../gh_completer/cmd/variable_delete.go | 2 +- completers/gh_completer/cmd/variable_get.go | 31 +++++++++++++++++++ completers/gh_completer/cmd/variable_set.go | 2 +- 5 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 completers/gh_completer/cmd/variable_get.go diff --git a/completers/gh_completer/cmd/action/pullrequest.go b/completers/gh_completer/cmd/action/pullrequest.go index 707a411e14..5070f0edde 100644 --- a/completers/gh_completer/cmd/action/pullrequest.go +++ b/completers/gh_completer/cmd/action/pullrequest.go @@ -111,6 +111,20 @@ func ActionPullRequestFields() carapace.Action { ) } +func ActionPullRequestCheckFields() carapace.Action { + return carapace.ActionValues( + "name", + "state", + "startedAt", + "completedAt", + "link", + "bucket", + "event", + "workflow", + "description", + ) +} + func actionPullRequests(cmd *cobra.Command, id string, f func(p pullrequest) carapace.Action) carapace.Action { return carapace.ActionCallback(func(c carapace.Context) carapace.Action { repo, err := repoOverride(cmd, c) diff --git a/completers/gh_completer/cmd/pr_checks.go b/completers/gh_completer/cmd/pr_checks.go index 4afa825d02..66a35691d5 100644 --- a/completers/gh_completer/cmd/pr_checks.go +++ b/completers/gh_completer/cmd/pr_checks.go @@ -18,11 +18,18 @@ func init() { pr_checksCmd.Flags().Bool("fail-fast", false, "Exit watch mode on first check failure") pr_checksCmd.Flags().StringP("interval", "i", "", "Refresh interval in seconds when using `--watch` flag") + pr_checksCmd.Flags().StringP("jq", "q", "", "Filter JSON output using a jq `expression`") + pr_checksCmd.Flags().StringSlice("json", []string{}, "Output JSON with the specified `fields`") pr_checksCmd.Flags().Bool("required", false, "Only show checks that are required") + pr_checksCmd.Flags().StringP("template", "t", "", "Format JSON output using a Go template; see \"gh help formatting\"") pr_checksCmd.Flags().Bool("watch", false, "Watch checks until they finish") pr_checksCmd.Flags().BoolP("web", "w", false, "Open the web browser to show details about checks") prCmd.AddCommand(pr_checksCmd) + carapace.Gen(pr_checksCmd).FlagCompletion(carapace.ActionMap{ + "json": action.ActionPullRequestCheckFields().UniqueList(","), + }) + carapace.Gen(pr_checksCmd).PositionalCompletion( carapace.ActionCallback(func(c carapace.Context) carapace.Action { return carapace.Batch( diff --git a/completers/gh_completer/cmd/variable_delete.go b/completers/gh_completer/cmd/variable_delete.go index e2286a657b..9358e1b2a8 100644 --- a/completers/gh_completer/cmd/variable_delete.go +++ b/completers/gh_completer/cmd/variable_delete.go @@ -22,7 +22,7 @@ func init() { variableCmd.AddCommand(variable_deleteCmd) carapace.Gen(variable_deleteCmd).FlagCompletion(carapace.ActionMap{ - "env": action.ActionEnvironments(variable_listCmd), + "env": action.ActionEnvironments(variable_deleteCmd), "org": gh.ActionOrganizations(gh.HostOpts{}), }) diff --git a/completers/gh_completer/cmd/variable_get.go b/completers/gh_completer/cmd/variable_get.go new file mode 100644 index 0000000000..d76ace6da2 --- /dev/null +++ b/completers/gh_completer/cmd/variable_get.go @@ -0,0 +1,31 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/carapace-sh/carapace-bin/completers/gh_completer/cmd/action" + "github.com/carapace-sh/carapace-bin/pkg/actions/tools/gh" + "github.com/spf13/cobra" +) + +var variable_getCmd = &cobra.Command{ + Use: "get ", + Short: "Get variables", + Run: func(cmd *cobra.Command, args []string) {}, +} + +func init() { + carapace.Gen(variable_getCmd).Standalone() + + variable_getCmd.Flags().StringP("env", "e", "", "Get a variable for an environment") + variable_getCmd.Flags().StringP("org", "o", "", "Get a variable for an organization") + variableCmd.AddCommand(variable_getCmd) + + carapace.Gen(variable_setCmd).FlagCompletion(carapace.ActionMap{ + "env": action.ActionEnvironments(variable_setCmd), + "org": gh.ActionOrganizations(gh.HostOpts{}), + }) + + carapace.Gen(variable_getCmd).PositionalCompletion( + action.ActionVariables(variable_getCmd), + ) +} diff --git a/completers/gh_completer/cmd/variable_set.go b/completers/gh_completer/cmd/variable_set.go index b7b64088a0..b49402c1e6 100644 --- a/completers/gh_completer/cmd/variable_set.go +++ b/completers/gh_completer/cmd/variable_set.go @@ -25,7 +25,7 @@ func init() { variableCmd.AddCommand(variable_setCmd) carapace.Gen(variable_setCmd).FlagCompletion(carapace.ActionMap{ - "env": action.ActionEnvironments(variable_listCmd), + "env": action.ActionEnvironments(variable_setCmd), "env-file": carapace.ActionFiles(), "org": gh.ActionOrganizations(gh.HostOpts{}), "repos": gh.ActionOwnerRepositories(gh.HostOpts{}).UniqueList(","),