From 8375592eef9638c5099b4b1c4b9df1c448dd7e34 Mon Sep 17 00:00:00 2001 From: rsteube Date: Sun, 14 Apr 2024 22:37:21 +0200 Subject: [PATCH] tldr: support variants --- cmd/carapace-generate/gen.go | 13 +++++++++++++ completers/tealdeer_completer/main.go | 7 ------- completers/tldr_completer/main.go | 2 +- completers/tldr_completer/{ => python}/cmd/root.go | 0 completers/tldr_completer/python/main.go | 7 +++++++ .../tealdeer}/cmd/root.go | 2 +- completers/tldr_completer/tealdeer/main.go | 7 +++++++ 7 files changed, 29 insertions(+), 9 deletions(-) delete mode 100644 completers/tealdeer_completer/main.go rename completers/tldr_completer/{ => python}/cmd/root.go (100%) create mode 100644 completers/tldr_completer/python/main.go rename completers/{tealdeer_completer => tldr_completer/tealdeer}/cmd/root.go (95%) create mode 100644 completers/tldr_completer/tealdeer/main.go diff --git a/cmd/carapace-generate/gen.go b/cmd/carapace-generate/gen.go index cf9c3b1ef4..4d5d185132 100644 --- a/cmd/carapace-generate/gen.go +++ b/cmd/carapace-generate/gen.go @@ -133,6 +133,19 @@ func readCompleters() ([]string, map[string]string) { description := readDescription(root, file.Name()) names = append(names, name) descriptions[name] = description + + if files, err := os.ReadDir(root + "/completers/" + file.Name()); err == nil { + for _, file := range files { + if file.IsDir() && file.Name() != "cmd" { // variants of completer (same binary name different ommand) + variant := fmt.Sprintf("%v/%v", name, file.Name()) + // description := readDescription(root, file.Name()) + description := "TODO" + names = append(names, variant) + descriptions[variant] = description + + } + } + } } } } diff --git a/completers/tealdeer_completer/main.go b/completers/tealdeer_completer/main.go deleted file mode 100644 index db651bf8c7..0000000000 --- a/completers/tealdeer_completer/main.go +++ /dev/null @@ -1,7 +0,0 @@ -package main - -import "github.com/carapace-sh/carapace-bin/completers/tealdeer_completer/cmd" - -func main() { - cmd.Execute() -} diff --git a/completers/tldr_completer/main.go b/completers/tldr_completer/main.go index 728eaac02e..fe1e7a564f 100644 --- a/completers/tldr_completer/main.go +++ b/completers/tldr_completer/main.go @@ -1,6 +1,6 @@ package main -import "github.com/carapace-sh/carapace-bin/completers/tldr_completer/cmd" +import "github.com/carapace-sh/carapace-bin/completers/tldr_completer/python/cmd" func main() { cmd.Execute() diff --git a/completers/tldr_completer/cmd/root.go b/completers/tldr_completer/python/cmd/root.go similarity index 100% rename from completers/tldr_completer/cmd/root.go rename to completers/tldr_completer/python/cmd/root.go diff --git a/completers/tldr_completer/python/main.go b/completers/tldr_completer/python/main.go new file mode 100644 index 0000000000..fe1e7a564f --- /dev/null +++ b/completers/tldr_completer/python/main.go @@ -0,0 +1,7 @@ +package main + +import "github.com/carapace-sh/carapace-bin/completers/tldr_completer/python/cmd" + +func main() { + cmd.Execute() +} diff --git a/completers/tealdeer_completer/cmd/root.go b/completers/tldr_completer/tealdeer/cmd/root.go similarity index 95% rename from completers/tealdeer_completer/cmd/root.go rename to completers/tldr_completer/tealdeer/cmd/root.go index e408f1b6c2..57d8bce845 100644 --- a/completers/tealdeer_completer/cmd/root.go +++ b/completers/tldr_completer/tealdeer/cmd/root.go @@ -41,7 +41,7 @@ func init() { carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{ "color": carapace.ActionValues("always", "auto", "never").StyleF(style.ForKeyword), "language": os.ActionLanguages(), - "platform": carapace.ActionValues("linux", "macos"), + "platform": carapace.ActionValues("linux", "macos", "windows", "sunos", "osx", "android"), "render": carapace.ActionFiles(), }) diff --git a/completers/tldr_completer/tealdeer/main.go b/completers/tldr_completer/tealdeer/main.go new file mode 100644 index 0000000000..6fe2a1423f --- /dev/null +++ b/completers/tldr_completer/tealdeer/main.go @@ -0,0 +1,7 @@ +package main + +import "github.com/carapace-sh/carapace-bin/completers/tldr_completer/tealdeer/cmd" + +func main() { + cmd.Execute() +}