Skip to content

Commit ccc4138

Browse files
committed
tmp
1 parent 8187553 commit ccc4138

1 file changed

Lines changed: 46 additions & 23 deletions

File tree

pkg/actions/bridge/bridge.go

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
"github.com/carapace-sh/carapace-bridge/pkg/bridges"
88
"github.com/carapace-sh/carapace-bridge/pkg/choices"
99
"github.com/carapace-sh/carapace-bridge/pkg/env"
10+
"github.com/carapace-sh/carapace/pkg/style"
11+
"github.com/carapace-sh/carapace/third_party/golang.org/x/sys/execabs"
1012
)
1113

1214
// TODO @ is now incompatible with variants and needs a new name
@@ -45,29 +47,50 @@ func Get(name string) (func(command ...string) carapace.Action, bool) {
4547
// cobra
4648
func ActionBridges() carapace.Action {
4749
return carapace.ActionCallback(func(c carapace.Context) carapace.Action {
48-
return carapace.ActionValuesDescribed(
49-
"argcomplete", "bridges https://github.com/kislyuk/argcomplete",
50-
"argcompleteV1", "bridges https://github.com/kislyuk/argcomplete",
51-
"aws", "bridges https://github.com/aws/aws-cli",
52-
"bash", "bridges completions registered in bash",
53-
"carapace-bin", "bridges completions registered in carapace-bin",
54-
"carapace", "bridges https://github.com/carapace-sh/carapace",
55-
"clap", "bridges https://github.com/clap-rs/clap",
56-
"click", "bridges https://github.com/pallets/click",
57-
"cobra", "bridges https://github.com/spf13/cobra",
58-
"complete", "bridges https://github.com/posener/complete",
59-
"fish", "bridges completions registered in fish",
60-
"gcloud", "bridges https://docs.cloud.google.com/sdk/gcloud",
61-
"inshellisense", "bridges https://github.com/microsoft/inshellisense",
62-
"kingpin", "bridges https://github.com/alecthomas/kingpin",
63-
"kitten", "bridges https://github.com/kovidgoyal/kitty",
64-
"macro", "bridges macros exposed with https://github.com/carapace-sh/carapace-spec",
65-
"powershell", "bridges completions registered in powershell",
66-
"urfavecli", "bridges https://github.com/urfave/cli (v2)",
67-
"urfavecliV1", "bridges https://github.com/urfave/cli (v3)",
68-
"yargs", "bridges https://github.com/yargs/yargs",
69-
"zsh", "bridges completions registered in zsh",
70-
).Tag("bridges")
50+
return carapace.Batch(
51+
carapace.ActionValuesDescribed(
52+
"argcomplete", "bridges https://github.com/kislyuk/argcomplete",
53+
"argcompleteV1", "bridges https://github.com/kislyuk/argcomplete",
54+
"carapace", "bridges https://github.com/carapace-sh/carapace",
55+
"clap", "bridges https://github.com/clap-rs/clap",
56+
"click", "bridges https://github.com/pallets/click",
57+
"cobra", "bridges https://github.com/spf13/cobra",
58+
"complete", "bridges https://github.com/posener/complete",
59+
"kingpin", "bridges https://github.com/alecthomas/kingpin",
60+
"macro", "bridges macros exposed with https://github.com/carapace-sh/carapace-spec",
61+
"urfavecli", "bridges https://github.com/urfave/cli (v2)",
62+
"urfavecliV1", "bridges https://github.com/urfave/cli (v3)",
63+
"yargs", "bridges https://github.com/yargs/yargs",
64+
).Style(style.Carapace.KeywordAmbiguous),
65+
carapace.ActionValuesDescribed(
66+
"aws", "bridges https://github.com/aws/aws-cli",
67+
"bash", "bridges completions registered in bash",
68+
"carapace-bin", "bridges completions registered in carapace-bin",
69+
"fish", "bridges completions registered in fish",
70+
"gcloud", "bridges https://docs.cloud.google.com/sdk/gcloud",
71+
"inshellisense", "bridges https://github.com/microsoft/inshellisense",
72+
"kitten", "bridges https://github.com/kovidgoyal/kitty",
73+
"powershell", "bridges completions registered in powershell",
74+
"zsh", "bridges completions registered in zsh",
75+
).StyleF(func(s string, sc style.Context) string {
76+
executable := map[string]string{
77+
"aws": "aws",
78+
"bash": "bash",
79+
"carapace-bin": "carapace",
80+
"fish": "fish",
81+
"gcloud": "gcloud",
82+
"inshellisense": "inshellisense",
83+
"kitten": "kitten",
84+
"powershell": "pwsh",
85+
"zsh": "zsh",
86+
}[s]
87+
88+
if _, err := execabs.LookPath(executable); err != nil {
89+
return style.Carapace.KeywordNegative
90+
}
91+
return style.Carapace.KeywordPositive
92+
}),
93+
).ToA().Tag("bridges")
7194
})
7295
}
7396

0 commit comments

Comments
 (0)