From 077aa7459224fc76693719e9634973dc0f196983 Mon Sep 17 00:00:00 2001 From: rsteube Date: Wed, 27 Sep 2023 09:45:05 +0200 Subject: [PATCH] gh: updates from v2.35.0 --- completers/gh_completer/cmd/alias_delete.go | 12 +++++++++--- completers/gh_completer/cmd/cache_list.go | 5 +++++ completers/gh_completer/cmd/release_create.go | 2 ++ pkg/actions/tools/gh/cache.go | 16 ++++++++++++++++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/completers/gh_completer/cmd/alias_delete.go b/completers/gh_completer/cmd/alias_delete.go index 4b7c769166..cfdcbf4e45 100644 --- a/completers/gh_completer/cmd/alias_delete.go +++ b/completers/gh_completer/cmd/alias_delete.go @@ -7,17 +7,23 @@ import ( ) var alias_deleteCmd = &cobra.Command{ - Use: "delete ", - Short: "Delete an alias", + Use: "delete { | --all}", + Short: "Delete set aliases", Run: func(cmd *cobra.Command, args []string) {}, } func init() { carapace.Gen(alias_deleteCmd).Standalone() + alias_deleteCmd.Flags().Bool("all", false, "Delete all aliases") aliasCmd.AddCommand(alias_deleteCmd) carapace.Gen(alias_deleteCmd).PositionalCompletion( - action.ActionAliases(), + carapace.ActionCallback(func(c carapace.Context) carapace.Action { + if alias_deleteCmd.Flag("all").Changed { + return carapace.ActionValues() + } + return action.ActionAliases() + }), ) } diff --git a/completers/gh_completer/cmd/cache_list.go b/completers/gh_completer/cmd/cache_list.go index d4b8d3ce76..17af3d721c 100644 --- a/completers/gh_completer/cmd/cache_list.go +++ b/completers/gh_completer/cmd/cache_list.go @@ -2,6 +2,7 @@ package cmd import ( "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/pkg/actions/tools/gh" "github.com/rsteube/carapace/pkg/style" "github.com/spf13/cobra" ) @@ -16,12 +17,16 @@ var cache_listCmd = &cobra.Command{ func init() { carapace.Gen(cache_listCmd).Standalone() + cache_listCmd.Flags().StringP("jq", "q", "", "Filter JSON output using a jq `expression`") + cache_listCmd.Flags().StringSlice("json", []string{}, "Output JSON with the specified `fields`") cache_listCmd.Flags().StringP("limit", "L", "", "Maximum number of caches to fetch") cache_listCmd.Flags().StringP("order", "O", "", "Order of caches returned: {asc|desc}") cache_listCmd.Flags().StringP("sort", "S", "", "Sort fetched caches: {created_at|last_accessed_at|size_in_bytes}") + cache_listCmd.Flags().StringP("template", "t", "", "Format JSON output using a Go template; see \"gh help formatting\"") cacheCmd.AddCommand(cache_listCmd) carapace.Gen(cache_listCmd).FlagCompletion(carapace.ActionMap{ + "json": gh.ActionCacheFields().UniqueList(","), "order": carapace.ActionValues("asc", "desc").StyleF(style.ForKeyword), "sort": carapace.ActionValues("created_at", "last_accessed_at", "size_in_bytes"), }) diff --git a/completers/gh_completer/cmd/release_create.go b/completers/gh_completer/cmd/release_create.go index d5e9efcf61..995699c721 100644 --- a/completers/gh_completer/cmd/release_create.go +++ b/completers/gh_completer/cmd/release_create.go @@ -23,6 +23,7 @@ func init() { release_createCmd.Flags().Bool("latest", false, "Mark this release as \"Latest\" (default: automatic based on date and version)") release_createCmd.Flags().StringP("notes", "n", "", "Release notes") release_createCmd.Flags().StringP("notes-file", "F", "", "Read release notes from `file` (use \"-\" to read from standard input)") + release_createCmd.Flags().Bool("notes-from-tag", false, "Automatically generate notes from annotated tag") release_createCmd.Flags().String("notes-start-tag", "", "Tag to use as the starting point for generating release notes") release_createCmd.Flags().BoolP("prerelease", "p", false, "Mark the release as a prerelease") release_createCmd.Flags().String("target", "", "Target `branch` or full commit SHA (default: main branch)") @@ -33,6 +34,7 @@ func init() { carapace.Gen(release_createCmd).FlagCompletion(carapace.ActionMap{ "discussion-category": action.ActionDiscussionCategories(release_createCmd), "notes-file": carapace.ActionFiles(), + "notes-from-tag": action.ActionReleases(release_createCmd), "notes-start-tag": action.ActionReleases(release_createCmd), "target": action.ActionBranches(release_createCmd), }) diff --git a/pkg/actions/tools/gh/cache.go b/pkg/actions/tools/gh/cache.go index cac55c11d3..ac00ea3df9 100644 --- a/pkg/actions/tools/gh/cache.go +++ b/pkg/actions/tools/gh/cache.go @@ -37,3 +37,19 @@ func ActionCaches(opts RepoOpts) carapace.Action { }) }).Tag("caches") } + +// ActionCacheFields completes label fields +// +// id +// key +func ActionCacheFields() carapace.Action { + return carapace.ActionValues( + "createdAt", + "id", + "key", + "lastAccessedAt", + "ref", + "sizeInBytes", + "version", + ) +}