Make a cobra Command flag required

前端 未结 3 1785
野性不改
野性不改 2021-02-19 19:03

I\'ve created a cobra command and added a flag:

cmd.Flags().StringVarP(&primaryIP, \"primary-ip\", \"p\", \"\", \"Help text\")

Is there a w

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-19 19:43

    No, you have to check yourself whether the input is correct for your program.

    Note that this makes sense, since you may want to check if the input is correct at the same time. In your example you should check if the input exists AND if the input is a valid ip-address.

提交回复
热议问题