Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Feb 16, 2024
1 parent bd4df3a commit aa35a28
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/actions/tools/dagger/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"regexp"
"strings"
"time"
"unicode"

"github.com/rsteube/carapace"
"github.com/rsteube/carapace/pkg/cache"
Expand Down Expand Up @@ -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,
Expand All @@ -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":
Expand Down Expand Up @@ -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)
}

0 comments on commit aa35a28

Please sign in to comment.