Cobra: Flag without value

Created on 1 Feb 2019  路  3Comments  路  Source: spf13/cobra

Hi i just want to know if it is posible to declare a flag just with the shorthand and without requiring a value something like docker-compose up -d just the flag alone

Most helpful comment

Same question.

Same answer, I guess:

You can use a boolean flag to achieve this behaviour:
rootCmd.BoolVarP(&verbose, "verbose", "v", false, "verbose output")

All 3 comments

Yes, you can use a boolean flag to achieve this behaviour.
example: rootCmd.BoolVarP(&verbose, "verbose", "v", false, "verbose output")

Same question.

Same question.

Same answer, I guess:

You can use a boolean flag to achieve this behaviour:
rootCmd.BoolVarP(&verbose, "verbose", "v", false, "verbose output")

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lukasmalkmus picture lukasmalkmus  路  4Comments

pjbgf picture pjbgf  路  5Comments

joernott picture joernott  路  6Comments

eine picture eine  路  5Comments

umbynos picture umbynos  路  5Comments