Skip to content

Commit

Permalink
Merge pull request #2219 from rsteube/git-foreachref
Browse files Browse the repository at this point in the history
git: for-each-ref
  • Loading branch information
rsteube authored Feb 5, 2024
2 parents 6ece4cc + cfcf88e commit 7103508
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 32 deletions.
65 changes: 65 additions & 0 deletions completers/git_completer/cmd/for_each_ref.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/git"
"github.com/rsteube/carapace/pkg/style"
"github.com/spf13/cobra"
)

var forEachRefCmd = &cobra.Command{
Use: "for-each-ref",
Short: "Output information on each ref",
Run: func(cmd *cobra.Command, args []string) {},
GroupID: groups[group_low_level_interrogator].ID,
}

func init() {
carapace.Gen(forEachRefCmd).Standalone()

forEachRefCmd.Flags().String("color", "", "respect any colors specified in the --format option")
forEachRefCmd.Flags().String("contains", "", "only list refs which contain the specified commit")
forEachRefCmd.Flags().String("count", "", "limit refs")
forEachRefCmd.Flags().StringSlice("exclude", []string{}, "only list refs which do not match any excluded pattern(s)")
forEachRefCmd.Flags().String("format", "", "a string that interpolates %(fieldname) from a ref being shown")
forEachRefCmd.Flags().Bool("ignore-case", false, "sorting and filtering refs are case insensitive")
forEachRefCmd.Flags().String("merged", "", "only list refs whose tips are reachable from the specified commit")
forEachRefCmd.Flags().String("no-contains", "", "only list refs which don’t contain the specified commit")
forEachRefCmd.Flags().String("no-merged", "", "only list refs whose tips are not reachable from the specified commit")
forEachRefCmd.Flags().Bool("omit-empty", false, "do not print a newline after formatted refs")
forEachRefCmd.Flags().Bool("perl", false, "quote strings for perl")
forEachRefCmd.Flags().String("points-at", "", "only list refs which points at the given object")
forEachRefCmd.Flags().Bool("python", false, "quote strings for python")
forEachRefCmd.Flags().Bool("shell", false, "quote strings for shell ")
forEachRefCmd.Flags().StringSlice("sort", []string{}, "field name to sort on")
forEachRefCmd.Flags().Bool("stdin", false, "read patterns from standard input")
forEachRefCmd.Flags().Bool("tcl", false, "quote strings for tcl")
rootCmd.AddCommand(forEachRefCmd)

forEachRefCmd.MarkFlagsMutuallyExclusive(
"shell",
"perl",
"python",
"tcl",
)

carapace.Gen(forEachRefCmd).FlagCompletion(carapace.ActionMap{
"color": carapace.ActionValues("always", "never", "auto").StyleF(style.ForKeyword),
"contains": git.ActionRefs(git.RefOption{}.Default()),
"exclude": git.ActionRefs(git.RefOption{}.Default()),
"merged": git.ActionRefs(git.RefOption{}.Default()),
"no-contains": git.ActionRefs(git.RefOption{}.Default()),
"no-merged": git.ActionRefs(git.RefOption{}.Default()),
"points-at": git.ActionRefs(git.RefOption{}.Default()),
"sort": git.ActionFieldNames(),
})

carapace.Gen(forEachRefCmd).PositionalAnyCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
if forEachRefCmd.Flag("stdin").Changed {
return carapace.ActionValues()
}
return git.ActionRefs(git.RefOption{}.Default())
}),
)
}
32 changes: 0 additions & 32 deletions completers/git_completer/cmd/for_each_ref_generated.go

This file was deleted.

0 comments on commit 7103508

Please sign in to comment.