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
I've got a task which can take an optional list of variants, where the list of variants is user-defined in the configuration: variants = [variant_1, variant_2, variant_3, etc...]
By default (no flags), the task needs to operate with the full list of variants, but I also need a --no-variants flag to disable all variants completely (effectively --variants => variants = [variant_1, variant_2, variant_3, etc...] and --no-variants => variants = [])
In addition, I need to allow a user to specify a specific subset of the variants, e.g. --variant=variant_1 --variant=variant_3 => variants = [variant_1, variant_3].
Right now, I'm considering using two flags --variants (boolean) and --variant (iterable), where the --variant flag would only be allowed if the --no-variants flag was not specified (i.e. variants = True). So for example, the following combinations would be valid:
It feels a bit awkward to me to have two flags named --variants and --variant that I need to resolve, when I really just want behavior like the following:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I've got a task which can take an optional list of variants, where the list of variants is user-defined in the configuration:
variants = [variant_1, variant_2, variant_3, etc...]
By default (no flags), the task needs to operate with the full list of variants, but I also need a
--no-variants
flag to disable all variants completely (effectively--variants
=>variants = [variant_1, variant_2, variant_3, etc...]
and--no-variants
=>variants = []
)In addition, I need to allow a user to specify a specific subset of the variants, e.g.
--variant=variant_1 --variant=variant_3
=>variants = [variant_1, variant_3]
.Right now, I'm considering using two flags
--variants
(boolean) and--variant
(iterable), where the--variant
flag would only be allowed if the--no-variants
flag was not specified (i.e.variants = True
). So for example, the following combinations would be valid:invoke task
=>variants = True
,variant = []
invoke task --variants
=>variants = True
,variant = []
invoke task --no-variants
=>variants = False
,variant = []
invoke task --variant=variant_1 --variant=variant_3
=>variants = True
,variant = [variant_1, variant_3]
invoke task --variants --variant=variant_1 --variant=variant_3
=>variants = True
,variants = [variant_1, variant_3]
It feels a bit awkward to me to have two flags named
--variants
and--variant
that I need to resolve, when I really just want behavior like the following:invoke task
=>variants = [variant_1, variant_2, variant_3, etc...]
invoke task --variants
=>variants = [variant_1, variant_2, variant_3, etc...]
invoke task --no-variants
=>variants = []
invoke task --variant=variant_1 --variant=variant_3
=>variants = [variant_1, variant_3]
I'm wondering if Invoke has a better way of doing this. Is there a way to specify a single flag that is both optional and iterable?
Beta Was this translation helpful? Give feedback.
All reactions