A small task runner inspired from npm
Project description
A small task runner inspired from npm.
Features
Use it like setuptools.
Chain tasks with _pre, _err, _post suffix.
A builtin Bump task which can bump version with semver.
Install
pip install pyxcute
Usage
Basic
Create a cute.py file like this:
from xcute import cute
cute(
hello = 'echo hello xcute!'
)
then run:
>cute hello
hello...
hello xcute!
If you didn’t provide the command, it will try to execute default task.
Provide additional arguments:
>cute hello 123
hello...
hello xcute! 123
The arguments will be passed into the runner, which is xcute.Cmd.__call__ in this case.
Tasks
It can be a str:
from xcute import cute
cute(
hello = 'echo hello'
)
If it is the name of another task, it will execute that task:
from xcute import cute
cute(
hello = 'world',
world = 'echo execute world task'
)
use a list:
from xcute import cute
cute(
hello = ['echo task1', 'echo task2']
)
or anything that is callable:
from xcute import cute
cute(
hello = lambda: print('say hello')
)
Task chain
Define the workflow with _pre, _err, _post suffix:
from xcute import cute
cute(
hello_pre = 'echo _pre runs before the task',
hello = 'echo say hello',
hello_err = 'echo _err runs if there is an error in task, i.e, an uncaught exception or non-zero return code',
hello_post = 'echo _post runs after the task if task successfully returned'
)
When a task is involved, it will firstly try to execute _pre task, then the task itself, then the _post task. If the task raised an exception, then it goes to _err task. Just like npm’s scripts.
Format string
pyXcute will expand format string with xcute.conf dictionary. Extend it as you need. By the default, it has following keys:
date - datetime.datetime.now().
tty - a boolean shows if the output is a terminal.
version - version number. Only available after Bump task or Version task.
old_version - version number before bump. Only available after Bump task.
tasks - a dictionary. This is what you send to cute().
init - command name.
args - additional argument list.
name - the name of current task.
Live example
Checkout the cute file of pyXcute itself.
xcute.Bump
Bump is a builtin task which can bump version like __version__ = '0.0.0'
from xcute import cute, Bump
cute(
bump = Bump('path/to/target/file')
)
then run
cute bump [major|minor|patch|prerelease|build]
the argument is optional, default to patch.
xcute.Version
This task will extract the version number into conf.
Changelog
0.1.2 (Apr 20, 2016)
Move _pre out of try clause.
0.1.1 (Apr 20, 2016)
Bump dev status.
0.1.0 (Apr 20, 2016)
First release.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pyxcute-0.1.2.zip
.
File metadata
- Download URL: pyxcute-0.1.2.zip
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c5f3dbe1fdac2b915f1614199f979be969d3d2cd813adf4d6829961e51c8ca4 |
|
MD5 | 0040763f5916d3fb7f19c8d582af4ef3 |
|
BLAKE2b-256 | 3dc46f8c6d5301baf66d389d81a7cce052eb40983e0339bf83197fbaf8922390 |
File details
Details for the file pyxcute-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: pyxcute-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b213c03ed2595a17f3e9be04fe65e6ea18a8bbf8f6640b9fa6e10856ed392028 |
|
MD5 | de8c8d16c04cb8f6a975eb423e945a4b |
|
BLAKE2b-256 | dd407a61110168452205428e6a30c7e140a6a93c050b63d750fe65556bd04602 |