List of tasks to be executed #706

rsaikali opened this Issue Aug 16, 2012 · 5 comments


None yet

2 participants



I'm looking for a way to find all the tasks to be executed.

$ fab -H myhost task1 task2

env.tasks (or whatever) could be set to ['task1', 'task2']



It's not part of the public API, but you can do this:

import fabric.state

print fabric.state.commands.keys()

fabric.state.commands is the data structure fab builds when it parses args & such. It's a dict of the form {'task_name': task_object}.

@bitprophet bitprophet closed this Aug 16, 2012

Thanks for the quick reply.

But it seems to give me the entire list of tasks for the current fabfile (it can be useful too... I was parsing a 'fab -l' to find these...).
It doesn't give me those asked to be executed.

fab -H myhost task1 task2
['task1', 'task2', 'task3', 'task4']

I was expecting :

['task1', 'task2']

Found from fabric.main, in command line parsing :

parser, options, arguments = parse_options()

where arguments is the list of tasks asked to be run... (but maybe other stuff... need to test more...).


Sorry, my bad -- I tested on a quick test fabfile. You're right -- we don't store the parsed info into env. It would be simple to do so -- if you want to dig into it I'd totally accept a patch.

@bitprophet bitprophet reopened this Aug 17, 2012

Moving to #709

@bitprophet bitprophet closed this Aug 20, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment