-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
78 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/git" | ||
"github.com/rsteube/carapace-bin/pkg/actions/os" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var tagCmd = &cobra.Command{ | ||
Use: "tag", | ||
Short: "Create, list, delete or verify a tag object signed with GPG", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(tagCmd).Standalone() | ||
|
||
tagCmd.Flags().BoolS("n", "n", false, "print <n> lines of each tag message") | ||
tagCmd.Flags().BoolP("annotate", "a", false, "annotated tag, needs a message") | ||
tagCmd.Flags().String("cleanup", "", "how to strip spaces and #comments from message") | ||
tagCmd.Flags().String("color", "", "respect format colors") | ||
tagCmd.Flags().String("column", "", "show tag list in columns") | ||
tagCmd.Flags().String("contains", "", "print only tags that contain the commit") | ||
tagCmd.Flags().Bool("create-reflog", false, "create a reflog") | ||
tagCmd.Flags().BoolP("delete", "d", false, "delete tags") | ||
tagCmd.Flags().BoolP("edit", "e", false, "force edit of tag message") | ||
tagCmd.Flags().StringP("file", "F", "", "read message from file") | ||
tagCmd.Flags().BoolP("force", "f", false, "replace the tag if exists") | ||
tagCmd.Flags().String("format", "", "format to use for the output") | ||
tagCmd.Flags().BoolP("ignore-case", "i", false, "sorting and filtering are case insensitive") | ||
tagCmd.Flags().BoolP("list", "l", false, "list tag names") | ||
tagCmd.Flags().StringP("local-user", "u", "", "use another key to sign the tag") | ||
tagCmd.Flags().String("merged", "", "print only tags that are merged") | ||
tagCmd.Flags().StringP("message", "m", "", "tag message") | ||
tagCmd.Flags().String("no-contains", "", "print only tags that don't contain the commit") | ||
tagCmd.Flags().String("no-merged", "", "print only tags that are not merged") | ||
tagCmd.Flags().String("points-at", "", "print only tags of the object") | ||
tagCmd.Flags().BoolP("sign", "s", false, "annotated and GPG-signed tag") | ||
tagCmd.Flags().String("sort", "", "field name to sort on") | ||
tagCmd.Flags().BoolP("verify", "v", false, "verify tags") | ||
rootCmd.AddCommand(tagCmd) | ||
|
||
tagCmd.Flag("color").NoOptDefVal = " " | ||
|
||
carapace.Gen(tagCmd).FlagCompletion(carapace.ActionMap{ | ||
"file": carapace.ActionFiles(), | ||
"cleanup": git.ActionCleanupMode(), | ||
"local-user": os.ActionGpgKeyIds(), | ||
"contains": git.ActionRefs(git.RefOption{Commits: 100}), | ||
"no-contains": git.ActionRefs(git.RefOption{Commits: 100}), | ||
"merged": git.ActionRefs(git.RefOption{Commits: 100}), | ||
"no-merged": git.ActionRefs(git.RefOption{Commits: 100}), | ||
"points-at": git.ActionRefs(git.RefOption{LocalBranches: true, RemoteBranches: true, Commits: 100}), | ||
"color": carapace.ActionValues("always", "never", "auto"), | ||
}) | ||
|
||
carapace.Gen(tagCmd).PositionalAnyCompletion( | ||
carapace.ActionCallback(func(c carapace.Context) carapace.Action { | ||
if tagCmd.Flag("delete").Changed || | ||
tagCmd.Flag("list").Changed || | ||
tagCmd.Flag("verify").Changed { | ||
return git.ActionRefs(git.RefOption{Tags: true}).Invoke(c).Filter(c.Args).ToA() | ||
} | ||
switch len(c.Args) { | ||
case 0: | ||
return git.ActionRefs(git.RefOption{Tags: true}) | ||
case 1: | ||
return git.ActionRefs(git.RefOption{LocalBranches: true, Commits: 100}) | ||
default: | ||
return carapace.ActionValues() | ||
} | ||
}), | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters