Skip to content

Commit

Permalink
codegen: support special characters
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Feb 13, 2024
1 parent 9ec6b79 commit 13c61db
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ func (s codegenCmd) formatGroups() string {

groups := make([]string, 0)
for _, group := range s.cmd.Groups() {
groups = append(groups, fmt.Sprintf(`&cobra.Group{ID: "%v", Title: "%v"},`, group.ID, group.Title))
groups = append(groups, fmt.Sprintf(`&cobra.Group{ID: %#v, Title: %#v},`, group.ID, group.Title))
}
return fmt.Sprintf("%vCmd.AddGroup(\n%v\n)\n", cmdVarName(s.cmd), strings.Join(groups, "\n"))
}

func (s codegenCmd) formatCommand() string {
snippet := fmt.Sprintf(
`var %vCmd = &cobra.Command{
Use: "%v",
Short: "%v",
GroupID: "%v",
Aliases: []string{"%v"},
Use: %#v,
Short: %#v,
GroupID: %#v,
Aliases: []string{%#v},
Hidden: %v,
Run: func(cmd *cobra.Command, args []string) {},
}
Expand Down

0 comments on commit 13c61db

Please sign in to comment.