For example when running cobra add-user the name of the command in the code is add-userCmd which is wrong.
Exact issue for me.
I need - because external app calls appname backup-end and I can't change that
Just clarifying, this is only an issue with the Cobra generation tool, not with the library itself, correct?
No idea, I'm still learning Go :)
@spf13 yes I think it's just generation.
Yes, just in generation:
$ cobra add get-metadata
$ go run main.go
# github.com/jdub/cfn-init-tools/cmd
cmd\get-metadata.go:30: syntax error: unexpected -
cmd\get-metadata.go:39: syntax error: unexpected {, expecting name
cmd\get-metadata.go:41: syntax error: unexpected fmt, expecting (
cmd\get-metadata.go:41: method has multiple receivers
cmd\get-metadata.go:42: syntax error: non-declaration statement outside function body
Lines 30 and 46:
var get-metadataCmd = &cobra.Command{
...
RootCmd.AddCommand(get-metadataCmd)
Probably makes sense to automagically camel case dashed (or underscored, ew, why) commands, e.g. getMetadataCmd.
It seems that, dash in command name will be camel cased now. What should I do if I want to have a command name with dash ?
It seems that, dash in command name will be camel cased now. What should I do if I want to have a command name with dash ?
I got it. Just change "Use" in cobra.Command {}
@lzhecheng More specifically, the alias field can be used. I was wondering the same.
var foobarCmd = &cobra.Command{
Use: "foobar",
Aliases: []string{"foo-bar", "FooBar"},
...
Most helpful comment
I got it. Just change "Use" in cobra.Command {}