gogo-cobra

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


Solution

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