简体   繁体   中英

How to implement multiple options with cobra

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

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")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM