You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After writing this, I thought "path" would only work to require when running testSubCmd. However, I was able to see the error that "path" was required when requesting another command (for example, a command of another package implemented in the same way). (This was not only true for 'MarkFlagsRequiredTogether' but also for 'MarkFlagRequired' and so on.)
In this case, is there a way to resolve it in cobra?
The text was updated successfully, but these errors were encountered:
This is probably because you have declared --path as a persistent flag: testCmd.PersistentFlags().StringVar(&path, "path", "", "Path to mount"). A persistent flag applies to the command and all its sub-commands.
You can instead try: testCmd.Flags().StringVar(&path, "path", "", "Path to mount")
After writing this, I thought "path" would only work to require when running testSubCmd. However, I was able to see the error that "path" was required when requesting another command (for example, a command of another package implemented in the same way). (This was not only true for 'MarkFlagsRequiredTogether' but also for 'MarkFlagRequired' and so on.)
In this case, is there a way to resolve it in cobra?
The text was updated successfully, but these errors were encountered: