From bdf71c318cd53299bab42ead7200bcf781006638 Mon Sep 17 00:00:00 2001 From: rsteube Date: Fri, 26 Mar 2021 00:10:56 +0100 Subject: [PATCH] git: added difftool --- .../{difftool_generated.go => difftool.go} | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) rename completers/git_completer/cmd/{difftool_generated.go => difftool.go} (51%) diff --git a/completers/git_completer/cmd/difftool_generated.go b/completers/git_completer/cmd/difftool.go similarity index 51% rename from completers/git_completer/cmd/difftool_generated.go rename to completers/git_completer/cmd/difftool.go index 02a3b82bf9..72862c6dfb 100644 --- a/completers/git_completer/cmd/difftool_generated.go +++ b/completers/git_completer/cmd/difftool.go @@ -1,25 +1,37 @@ package cmd import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/pkg/actions/git" "github.com/spf13/cobra" ) var difftoolCmd = &cobra.Command{ Use: "difftool", Short: "Show changes using common diff tools", - Run: func(cmd *cobra.Command, args []string) { - }, + Run: func(cmd *cobra.Command, args []string) {}, } func init() { + carapace.Gen(difftoolCmd).Standalone() + difftoolCmd.Flags().BoolP("dir-diff", "d", false, "perform a full-directory diff") + difftoolCmd.Flags().StringP("extcmd", "x", "", "specify a custom command for viewing diffs") difftoolCmd.Flags().BoolP("gui", "g", false, "use `diff.guitool` instead of `diff.tool`") difftoolCmd.Flags().Bool("no-index", false, "passed to `diff`") + difftoolCmd.Flags().BoolP("no-prompt", "y", false, "do not prompt before launching a diff tool") difftoolCmd.Flags().Bool("symlinks", false, "use symlinks in dir-diff mode") + difftoolCmd.Flags().StringP("tool", "t", "", "use the specified diff tool") difftoolCmd.Flags().Bool("tool-help", false, "print a list of diff tools that may be used with `--tool`") - difftoolCmd.Flags().Bool("trust-exit-code", false, "make 'git-difftool' exit when an invoked diff tool returns a non - zero exit code") - difftoolCmd.Flags().BoolP("tool", "t", false, " use the specified diff tool") - difftoolCmd.Flags().BoolP("extcmd", "x", false, " specify a custom command for viewing diffs") - difftoolCmd.Flags().BoolP("no-prompt", "y", false, "do not prompt before launching a diff tool") + difftoolCmd.Flags().Bool("trust-exit-code", false, "exit when an invoked diff tool returns a non - zero exit code") rootCmd.AddCommand(difftoolCmd) + + carapace.Gen(difftoolCmd).FlagCompletion(carapace.ActionMap{ + "tool": carapace.ActionFiles(), + }) + + carapace.Gen(difftoolCmd).PositionalCompletion( + git.ActionRefs(git.RefOptionDefault), + git.ActionRefs(git.RefOptionDefault), + ) }