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'd like to be able to use the argparase "count" action. A common use for this is something like program -v to enable verbose message and then program -vv or program -v -v to increase the verbosity.
Is there a simple way to achieve this with a custom parser? It wouldn't actually accept a string, so maybe not. I have no tried that though.
I suppose this could use the same solution as proposed in #95. I've added another comment there.
The text was updated successfully, but these errors were encountered:
Spectre5
changed the title
feature request: support "count"
feature request: support "count" action
Jan 22, 2022
I don't think this is possible right now. Something like #95 is perhaps possible. Alternatively I thought that we may be able to introduce a type alias like defopt.Count = int and special-case those, but type aliases don't exist at runtime; or a NewType (defopt.Count = NewType("Count", int)) but I think that would prevent (from a mypy PoV) from directly calling the function with an int, which may or may not be a problem?
Ya, I had considered some sort of custom type too, but I had the same concern with mypy. Perhaps a solution could be found in a union type with a custom one (considered first) or an int (i.e. Union[CustomInt, int]). With that said, at this point we're changing the function anyway and then the solution in #95 is better and could cover this use case.
I'd like to be able to use the argparase "count" action. A common use for this is something like
program -v
to enable verbose message and thenprogram -vv
orprogram -v -v
to increase the verbosity.Is there a simple way to achieve this with a custom parser? It wouldn't actually accept a string, so maybe not. I have no tried that though.
I suppose this could use the same solution as proposed in #95. I've added another comment there.
The text was updated successfully, but these errors were encountered: