| 1 |
.. include:: ../../README.rst |
| 2 |
|
| 3 |
This website covers project information for Invoke such as the changelog, |
| 4 |
contribution guidelines, development roadmap, news/blog, and so forth. |
| 5 |
Detailed usage and API documentation can be found at our code documentation |
| 6 |
site, `docs.pyinvoke.org <https://docs.pyinvoke.org>`_. |
| 7 |
|
| 8 |
Please see below for a high level intro, or the navigation on the left for the |
| 9 |
rest of the site content. |
| 10 |
|
| 11 |
What is Invoke? |
| 12 |
--------------- |
| 13 |
|
| 14 |
* Like Ruby's Rake tool and Invoke's own predecessor Fabric 1.x, it provides a |
| 15 |
clean, high level API for running shell commands and defining/organizing |
| 16 |
task functions from a ``tasks.py`` file: |
| 17 |
|
| 18 |
.. code-block:: python |
| 19 |
|
| 20 |
from invoke import task |
| 21 |
|
| 22 |
@task |
| 23 |
def clean(c, docs=False, bytecode=False, extra=''): |
| 24 |
patterns = ['build'] |
| 25 |
if docs: |
| 26 |
patterns.append('docs/_build') |
| 27 |
if bytecode: |
| 28 |
patterns.append('**/*.pyc') |
| 29 |
if extra: |
| 30 |
patterns.append(extra) |
| 31 |
for pattern in patterns: |
| 32 |
c.run("rm -rf {}".format(pattern)) |
| 33 |
|
| 34 |
@task |
| 35 |
def build(c, docs=False): |
| 36 |
c.run("python setup.py build") |
| 37 |
if docs: |
| 38 |
c.run("sphinx-build docs docs/_build") |
| 39 |
|
| 40 |
* From GNU Make, it inherits an emphasis on minimal boilerplate for common |
| 41 |
patterns and the ability to run multiple tasks in a single invocation:: |
| 42 |
|
| 43 |
$ invoke clean build |
| 44 |
|
| 45 |
* Where Fabric 1.x considered the command-line approach the default mode of |
| 46 |
use, Invoke (and tools built on it) are equally at home embedded in your own |
| 47 |
Python code or a REPL: |
| 48 |
|
| 49 |
.. testsetup:: blurb |
| 50 |
|
| 51 |
fakeout = """ |
| 52 |
Hello, this is pip |
| 53 |
Installing is fun |
| 54 |
Fake output is fake |
| 55 |
Successfully installed invocations-0.13.0 pep8-1.5.7 spec-1.3.1 |
| 56 |
""" |
| 57 |
proc = MockSubprocess(out=fakeout, exit=0) |
| 58 |
|
| 59 |
.. testcleanup:: blurb |
| 60 |
|
| 61 |
proc.stop() |
| 62 |
|
| 63 |
.. doctest:: blurb |
| 64 |
|
| 65 |
>>> from invoke import run |
| 66 |
>>> cmd = "pip install -r requirements.txt" |
| 67 |
>>> result = run(cmd, hide=True, warn=True) |
| 68 |
>>> print(result.ok) |
| 69 |
True |
| 70 |
>>> print(result.stdout.splitlines()[-1]) |
| 71 |
Successfully installed invocations-0.13.0 pep8-1.5.7 spec-1.3.1 |
| 72 |
|
| 73 |
* Following the lead of most Unix CLI applications, it offers a traditional |
| 74 |
flag-based style of command-line parsing, deriving flag names and value types |
| 75 |
from task signatures (optionally, of course!):: |
| 76 |
|
| 77 |
$ invoke clean --docs --bytecode build --docs --extra='**/*.pyo' |
| 78 |
$ invoke clean -d -b build --docs -e '**/*.pyo' |
| 79 |
$ invoke clean -db build -de '**/*.pyo' |
| 80 |
|
| 81 |
* Like many of its predecessors, it offers advanced features as well -- |
| 82 |
namespacing, task aliasing, before/after hooks, parallel execution and more. |
| 83 |
|
| 84 |
|
| 85 |
.. toctree:: |
| 86 |
:hidden: |
| 87 |
|
| 88 |
changelog |
| 89 |
FAQs <faq> |
| 90 |
installing |
| 91 |
development |
| 92 |
prior-art |
| 93 |
contact |