Skip to content

Commit

Permalink
examples are fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
kmike committed Aug 28, 2012
1 parent 5328a9d commit c3d7318
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
1 change: 1 addition & 0 deletions .hgignore
Expand Up @@ -15,6 +15,7 @@ syntax: regexp
~$
\.DS_Store
Thumbs.db
^fabfile.py$

# build files
^dist/
Expand Down
26 changes: 21 additions & 5 deletions README.rst
Expand Up @@ -23,24 +23,37 @@ Example::


# fabfile.py
from fabric.api import local
from taskset import TaskSet, task_method

class SayBase(TaskSet):
def say(self, what):
raise NotImplemented()
raise NotImplementedError()

@task_method(default=True, alias='hi')
def hello(self):
self.say('hello')

@task_method
def bye(self):
self.say('goodbye')

class EchoSay(SayBase):
def say(self, what):
local('echo ' + what)

say = EchoSay().expose_as_module('say')


and then e.g.::
and then::

$ fab -l
Available commands:

say
say.bye
say.hello
say.hi

$ fab say.hi
hello
Expand All @@ -53,11 +66,11 @@ use it on methods just like fabric's decorator is used on functions.
You can also create an "on-disk" Python module and populate it with tasks::

# my_lib/say.py
from taskset import TaskSet, task_method
h from taskset import TaskSet, task_method

class SayBase(TaskSet):
def say(self, what):
raise NotImplemented()
raise NotImplementedError()

@task_method(default=True, alias='hi')
def hello(self):
Expand All @@ -84,4 +97,7 @@ and has a small deployment framework included.

In order to feed my NIH syndrome I create Fabric-taskset which
exposes new-style Fabric tasks, provides slightly different API and doesn't
have extra goodies.
have extra goodies.

This library then evolves to support exposing tasks without creating dummy
on-disk modules (thanks to Denis Untevskiy).
13 changes: 5 additions & 8 deletions taskset/__init__.py
Expand Up @@ -42,26 +42,23 @@ class TaskSet(object):
Example::
# my_lib/say.py
from taskset import TaskSet, task
# fabfile.py
from fabric.api import local
from taskset import TaskSet, task_method
class SayBase(TaskSet):
def say(self, what):
raise NotImplemented()
@task(default=True, alias='hi')
@task_method(default=True, alias='hi')
def hello(self):
self.say('hello')
class EchoSay(SayBase):
def say(self, what):
local('echo ' + what)
instance = EchoSay()
instance.expose_to_current_module()
# fabfile.py
from mylib import say
say = EchoSay().expose_as_module('say')
and then::
Expand Down

0 comments on commit c3d7318

Please sign in to comment.