Given the following python invoke script:
from invoke import task
@task
def pre(c):
print("pre")
@task(pre=[pre])
def command(c, flag):
print(f"command flag={flag}")
Called with the following shell command:
inv command --flag
I would like to read the value of flag
to conditionally do some actions in pre
. Is there a way I can read the flag
property passed to command
from within pre
using invoke's API? I couldn't find anything in the docs about it.
I am aware that push comes to shove, I can import sys and read the args directly, but I'd rather avoid doing that work manually if I can.