From aa35a281fbdf539080acecc914b6fe8798e4b893 Mon Sep 17 00:00:00 2001 From: rsteube Date: Fri, 16 Feb 2024 17:48:25 +0100 Subject: [PATCH] tmp --- pkg/actions/tools/dagger/function.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/actions/tools/dagger/function.go b/pkg/actions/tools/dagger/function.go index 513ed4f1fe..f4feaba9b1 100644 --- a/pkg/actions/tools/dagger/function.go +++ b/pkg/actions/tools/dagger/function.go @@ -6,6 +6,7 @@ import ( "regexp" "strings" "time" + "unicode" "github.com/rsteube/carapace" "github.com/rsteube/carapace/pkg/cache" @@ -89,6 +90,7 @@ func ActionFunctionsA() carapace.Action { cmd := &cobra.Command{} carapace.Gen(cmd).Standalone() for _, f := range functions { + f.Name = toKebab(f.Name) subCmd := &cobra.Command{ Use: f.Name, Short: f.Description, @@ -97,6 +99,8 @@ func ActionFunctionsA() carapace.Action { carapace.Gen(subCmd).Standalone() for _, arg := range f.Args { + arg.Name = toKebab(arg.Name) + // TODO transform camelcase to kebab switch arg.TypeDef.Kind { // TODO more types case "STRING_KIND", "OBJECT_KIND": @@ -132,3 +136,14 @@ func ActionFunctionsA() carapace.Action { return carapace.ActionExecute(cmd) }) } + +func toKebab(s string) string { + runes := make([]rune, 0) + for _, r := range []rune(s) { + if unicode.IsUpper(r) { + runes = append(runes, '-') + } + runes = append(runes, unicode.ToLower(r)) + } + return string(runes) +}