Skip to content

Commit 1627512

Browse files
author
Sam Cook
committed
Give a more useful output to fab help
When `fab help` is run with no further arguments it throws an error. This instead has it print out a list of available tasks.
1 parent c56bd85 commit 1627512

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fabfile.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import time
1010

1111
from fabric import state
12+
from fabric.main import show_commands
1213
from fabric.api import (abort, env, get, hide, hosts, local, puts, run,
1314
runs_once, serial, settings, sudo, task, warn)
1415
from fabric.task_utils import crawl
@@ -244,8 +245,11 @@ def _replace_environment_hostnames(environment):
244245

245246

246247
@task
247-
def help(name):
248+
def help(name=""):
248249
"""Show extended help for a task (e.g. 'fab help:search.reindex')"""
250+
if not name:
251+
puts("\nFor more information on a task run `fab help:<task>`.\n")
252+
show_commands(None, 'short')
249253
task = crawl(name, state.commands)
250254

251255
if task is None:

0 commit comments

Comments
 (0)