How to implement multiple options with cobra

huangapple go评论72阅读模式
英文:

How to implement multiple options with cobra

问题

我尝试了这个:
projCmd.Flags().StringVarP(&flag, "type", "t", flag, "help")

但是,如何像这样使用 cobra 实现多个选项:
mycli new -t one -n two

英文:

I try this:
projCmd.Flags().StringVarP(&flag, "type", "t", flag, "help")

But, how to implement multiple options with cobra like this:
mycli new -t one -n two

答案1

得分: 0

添加第二行,包含你想要添加的下一个选项。你不限于只使用一行。

例如:

projCmd.Flags().StringVarP(&flag, "type", "t", flag, "帮助信息")
projCmd.Flags().StringVarP(&flag2, "some", "s", flag2, "一些描述")
英文:

Add a second line with the next option you want to add. You are not limited to use one.

Eg:

projCmd.Flags().StringVarP(&flag, "type", "t", flag, "help")
projCmd.Flags().StringVarP(&flag2, "some", "s", flag2, "some description")

huangapple
  • 本文由 发表于 2021年7月9日 13:39:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/68311787.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定