diff --git a/README.md b/README.md index fa1edc2ba7..8f4eeb2167 100644 --- a/README.md +++ b/README.md @@ -73,3 +73,4 @@ exec($(carapace _carapace)) # zsh (~/.zshrc) source <(carapace _carapace) ``` +XXX diff --git a/completers/git_completer/cmd/stash.go b/completers/git_completer/cmd/stash.go index c02c4a019a..a2b7a0f95b 100644 --- a/completers/git_completer/cmd/stash.go +++ b/completers/git_completer/cmd/stash.go @@ -2,6 +2,7 @@ package cmd import ( "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/pkg/actions/tools/git" "github.com/spf13/cobra" ) @@ -15,4 +16,8 @@ var stashCmd = &cobra.Command{ func init() { carapace.Gen(stashCmd).Standalone() rootCmd.AddCommand(stashCmd) + + carapace.Gen(stashCmd).DashAnyCompletion( + git.ActionChanges(git.ChangeOpts{Unstaged: true}).FilterArgs(), + ) } diff --git a/completers/git_completer/cmd/stash_push.go b/completers/git_completer/cmd/stash_push.go index f9e53d7acd..7fe0a30294 100644 --- a/completers/git_completer/cmd/stash_push.go +++ b/completers/git_completer/cmd/stash_push.go @@ -2,6 +2,7 @@ package cmd import ( "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/pkg/actions/tools/git" "github.com/spf13/cobra" ) @@ -28,4 +29,17 @@ func init() { carapace.Gen(stash_pushCmd).FlagCompletion(carapace.ActionMap{ "pathspec-from-file": carapace.ActionFiles(), }) + + carapace.Gen(stash_pushCmd).PositionalAnyCompletion( + carapace.ActionCallback(func(c carapace.Context) carapace.Action { + if stash_pushCmd.Flag("pathspec-from-file").Changed { + return carapace.ActionValues() + } + return git.ActionChanges(git.ChangeOpts{Unstaged: true}) + }), + ) + + carapace.Gen(stash_pushCmd).DashAnyCompletion( + carapace.ActionPositional(stash_pushCmd), + ) }