Skip to content

Commit

Permalink
gum: added emoji completion
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Jan 13, 2023
1 parent 3b0efd2 commit 110b88d
Show file tree
Hide file tree
Showing 2 changed files with 1,765 additions and 0 deletions.
14 changes: 14 additions & 0 deletions completers/gum_completer/cmd/format.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package cmd

import (
"strings"

"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/gh"
"github.com/spf13/cobra"
)

Expand All @@ -24,4 +27,15 @@ func init() {
).ToA(),
"type": carapace.ActionValues("markdown", "template", "code", "emoji"),
})

carapace.Gen(formatCmd).PositionalAnyCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
if formatCmd.Flag("type").Value.String() == "emoji" {
if index := strings.LastIndex(c.CallbackValue, ":"); index != -1 {
return gh.ActionEmojis().Prefix(c.CallbackValue[:index])
}
}
return carapace.ActionValues()
}),
)
}
Loading

0 comments on commit 110b88d

Please sign in to comment.