From e54cbb7b253b07798de3a3674eac4346c539011b Mon Sep 17 00:00:00 2001 From: rsteube Date: Tue, 13 Aug 2024 17:31:02 +0200 Subject: [PATCH] git: ls-tree --- completers/git_completer/cmd/lsTree.go | 47 +++++++++++++++++++ .../git_completer/cmd/ls_tree_generated.go | 28 ----------- 2 files changed, 47 insertions(+), 28 deletions(-) create mode 100644 completers/git_completer/cmd/lsTree.go delete mode 100644 completers/git_completer/cmd/ls_tree_generated.go diff --git a/completers/git_completer/cmd/lsTree.go b/completers/git_completer/cmd/lsTree.go new file mode 100644 index 0000000000..6be43f012a --- /dev/null +++ b/completers/git_completer/cmd/lsTree.go @@ -0,0 +1,47 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/carapace-sh/carapace-bin/pkg/actions/tools/git" + "github.com/spf13/cobra" +) + +var lsTreeCmd = &cobra.Command{ + Use: "ls-tree", + Short: "List the contents of a tree object", + Run: func(cmd *cobra.Command, args []string) {}, + GroupID: groups[group_low_level_interrogator].ID, +} + +func init() { + carapace.Gen(lsTreeCmd).Standalone() + + lsTreeCmd.Flags().String("abbrev", "", "use digits to display object names") + lsTreeCmd.Flags().BoolS("d", "d", false, "only show trees") + lsTreeCmd.Flags().String("format", "", "format to use for the output") + lsTreeCmd.Flags().Bool("full-name", false, "use full path names") + lsTreeCmd.Flags().Bool("full-tree", false, "list entire tree") + lsTreeCmd.Flags().BoolP("long", "l", false, "include object size") + lsTreeCmd.Flags().Bool("name-only", false, "list only filenames") + lsTreeCmd.Flags().Bool("name-status", false, "list only filenames") + lsTreeCmd.Flags().Bool("no-abbrev", false, "do not use abbreviated digits to display object names") + lsTreeCmd.Flags().Bool("no-full-name", false, "do not use full path names") + lsTreeCmd.Flags().Bool("no-full-tree", false, "do not list entire tree") + lsTreeCmd.Flags().Bool("object-only", false, "list only objects") + lsTreeCmd.Flags().BoolS("r", "r", false, "recurse into subtrees") + lsTreeCmd.Flags().BoolS("t", "t", false, "show trees when recursing") + lsTreeCmd.Flags().BoolS("z", "z", false, "terminate entries with NUL byte") + rootCmd.AddCommand(lsTreeCmd) + + lsTreeCmd.Flag("abbrev").NoOptDefVal = " " + + carapace.Gen(lsTreeCmd).PositionalCompletion( + git.ActionRefs(git.RefOption{}.Default()), + ) + + carapace.Gen(lsTreeCmd).PositionalAnyCompletion( + carapace.ActionCallback(func(c carapace.Context) carapace.Action { + return git.ActionRefFiles(c.Args[0]) + }), + ) +} diff --git a/completers/git_completer/cmd/ls_tree_generated.go b/completers/git_completer/cmd/ls_tree_generated.go deleted file mode 100644 index 5655435070..0000000000 --- a/completers/git_completer/cmd/ls_tree_generated.go +++ /dev/null @@ -1,28 +0,0 @@ -package cmd - -import ( - "github.com/carapace-sh/carapace" - "github.com/spf13/cobra" -) - -var ls_treeCmd = &cobra.Command{ - Use: "ls-tree", - Short: "List the contents of a tree object", - Run: func(cmd *cobra.Command, args []string) {}, - GroupID: groups[group_low_level_interrogator].ID, -} - -func init() { - carapace.Gen(ls_treeCmd).Standalone() - ls_treeCmd.Flags().String("abbrev", "", "use digits to display SHA-1s") - ls_treeCmd.Flags().BoolS("d", "d", false, "only show trees") - ls_treeCmd.Flags().Bool("full-name", false, "use full path names") - ls_treeCmd.Flags().Bool("full-tree", false, "list entire tree; not just current directory (implies --full-name)") - ls_treeCmd.Flags().BoolP("long", "l", false, "include object size") - ls_treeCmd.Flags().Bool("name-only", false, "list only filenames") - ls_treeCmd.Flags().Bool("name-status", false, "list only filenames") - ls_treeCmd.Flags().BoolS("r", "r", false, "recurse into subtrees") - ls_treeCmd.Flags().BoolS("t", "t", false, "show trees when recursing") - ls_treeCmd.Flags().BoolS("z", "z", false, "terminate entries with NUL byte") - rootCmd.AddCommand(ls_treeCmd) -}