Skip to content

Commit

Permalink
Merge pull request #260 from rsteube/codegen-special-characters
Browse files Browse the repository at this point in the history
codegen: support special characters
  • Loading branch information
rsteube authored Feb 13, 2024
2 parents 9ec6b79 + 13c61db commit 9369324
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 9369324

Please sign in to comment.