Find a decent way to indicate, on a task or automatically, that e.g. invoke taskname --val=5 should result in a Python value 5 instead of "5", and of course similar for bools, lists etc.
Possibilities:
-
Explicit on the CLI level:
invoke mytask --wants-an-int int:5 --wants-a-list=list:"a;b;c"
-
Explicit on the task declaration level (off the cuff API, but you get the gist):
@task(argspec={'wants_an_int': int, 'wants_a_list': lambda x: x.split(';')})
def mytask(wants_an_int, wants_a_list):
# ...
-
Implicit via conventions, e.g. try/except casting to int and/or float, anything containing semicolons gets split()'d, etc
- Original ticket said to cast
y/yes/etc to booleans, but now that we're using --real --flags booleans happen for free.
- Would obviously need to be easily toggled, and think about what the default should be
-
Explicit via helper functions -- obviously int/float already exist, so maybe a helper def listarg(x): return x.split(';')
- Feels kinda dumb unless we can come up with a larger body of useful subroutines worth supporting.
Right now, I'm leaning towards the explicit-at-task-declaration level, with possible implicit-via-conventions. Very torn on whether the implicit should be on by default -- fits the "get stuff done fast" use case but clashes with "don't be surprising".
Was Fabric #69
Find a decent way to indicate, on a task or automatically, that e.g.
invoke taskname --val=5should result in a Python value5instead of"5", and of course similar for bools, lists etc.Possibilities:
Explicit on the CLI level:
Explicit on the task declaration level (off the cuff API, but you get the gist):
Implicit via conventions, e.g. try/except casting to
intand/orfloat, anything containing semicolons getssplit()'d, etcy/yes/etc to booleans, but now that we're using--real --flagsbooleans happen for free.Explicit via helper functions -- obviously
int/floatalready exist, so maybe a helperdef listarg(x): return x.split(';')Right now, I'm leaning towards the explicit-at-task-declaration level, with possible implicit-via-conventions. Very torn on whether the implicit should be on by default -- fits the "get stuff done fast" use case but clashes with "don't be surprising".
Was Fabric #69