Open RomanBurdiuzha opened 4 years ago
@RomanBurdiuzha
This should work:
from invoke import Collection, task
@task
def build(ctx):
print('some build here')
ns = Collection(build)
Then:
from invoke import Executor, task
from . import example
@task
def get_namespace_tasks(ctx):
e = Executor(example.ns)
print(e.collection.task_names)
Hello! I am updating from fab1 to fab2 with invoke and I need to get list of tasks user called during initiating fab command. In fab1 I had env.tasks and could iterate through this list.
How can I get list of tasks from invoke? I am trying to get it from context object but seems it doesn't return tasks. There is "tasks" collection, but I can't get list from it
Output
_<Context: <Config: {'run': {'asynchronous': False, 'disown': False, 'dry': False, 'echo': False, 'echo_stdin': None, 'encoding': None, 'env': {}, 'err_stream': None, 'fallback': True, 'hide': None, 'in_stream': None, 'out_stream': None, 'pty': False, 'replace_env': False, 'shell': 'C:\Windows\system32\cmd.exe', 'warn': False, 'watchers': []}, 'runners': {'local': <class 'invoke.runners.Local'>}, 'sudo': {'password': None, 'prompt': '[sudo] password: ', 'user': None}, 'tasks': {'auto_dash_names': True, 'collection_name': 'tasks', 'dedupe': True, 'executor_class': None, 'searchroot': None}, 'timeouts': {'command': None}}>>