-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLI arg typecasting #9
Comments
I have a partial implementation of this in master, which infers typing from the default value of arguments (both in terms of a task's argspec, and at the parser level, e.g. if anybody were to construct the parser arguments manually). Still needs to be expanded to allow something explicit for any args that lack default values. |
Years-later clarification: the "partial implementation" mentioned above has been a core part of the CLI framework for a long time and seems to work OK for many/most use cases; it's the functionality that knows when you have: @task
def mytask(c, count=5):
pass then this invocation results in
Combined with boolean true-flags ( Things like "no I really want SHORTER ways to supply lists" (can be solved on the user's end with |
Find a decent way to indicate, on a task or automatically, that e.g.
invoke taskname --val=5
should result in a Python value5
instead 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
int
and/orfloat
, anything containing semicolons getssplit()
'd, etcy
/yes
/etc to booleans, but now that we're using--real --flags
booleans happen for free.Explicit via helper functions -- obviously
int
/float
already 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
The text was updated successfully, but these errors were encountered: