-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
alias_set.go
32 lines (27 loc) · 987 Bytes
/
alias_set.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/completers/gh_completer/cmd/action"
"github.com/carapace-sh/carapace-bridge/pkg/actions/bridge"
"github.com/spf13/cobra"
)
var alias_setCmd = &cobra.Command{
Use: "set <alias> <expansion>",
Short: "Create a shortcut for a gh command",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(alias_setCmd).Standalone()
alias_setCmd.Flags().Bool("clobber", false, "Overwrite existing aliases of the same name")
alias_setCmd.Flags().BoolP("shell", "s", false, "Declare an alias to be passed through a shell interpreter")
aliasCmd.AddCommand(alias_setCmd)
carapace.Gen(alias_setCmd).PositionalCompletion(
action.ActionAliases(),
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
if !alias_setCmd.Flag("shell").Changed {
return bridge.ActionCarapaceBin("gh").Split()
}
return bridge.ActionCarapaceBin().SplitP()
}),
)
}