Moke transforms a Python module into a command line script. Every function can become a sub-command, with options inferred from the argument list and the optional doc string.
A command line application that greets exactly two persons. (put the following into a file called mokefile.py:
from moke import task, log
@task
def greet(who, shout=False, times=1):
"""
Sends greetings from moke.
- who(str2) two persons to greet
- shout(switch) triggers CAPS
"""
greetings = ("Hello %s and %s!" % (who[0], who[1])) * times
if shout:
greetings = greetings.upper()
log("greeted: %s and %s" % (who[0], who[1]), INFO)
if __name__ == "__main__":
task()
Execute the mokefile by calling moke:
moke greet --shout -times 2 Mary Kate
this returns:
2011-09-30 14:12:52,815 moke (version 1.0.0)
2011-09-30 14:12:52,815 cwd: "/home/.../moke/test/scripts"
2011-09-30 14:12:52,815 mokefile: "/home/.../moke/test/scripts/mokefile.py"
2011-09-30 14:12:52,815 task: greet
2011-09-30 14:12:52,815 params: ('who', ['Mary', 'Kate']) ('shout', True) ('times', 2)
HELLO MARY AND KATE!
HELLO MARY AND KATE!
If you forgot what your mokefile.py does, just ask for help:
moke --help
usage: mokefile.py [-h] [-ls LS] [-ll {info,warn,error}] [-lf {tab}]
{greet} ...
positional arguments:
{greet}
greet Sends greetings from moke.
optional arguments:
-h, --help show this help message and exit
-ls LS (file_a) [default: <stderr>] logging stream
-ll {info,warn,error}
(str) [default: info] logging level
-lf {tab} (str) [default: tab] logging format
Sub-command specific help is also generated:
moke greet --help usage: mokefile.py greet [-h] [--shout] [-times TIMES] who who positional arguments: who (str) two persons to greet optional arguments: -h, --help show this help message and exit --shout (switch) triggers CAPS -times TIMES (int) [default: 1]
Now it’s time to start your own Mokefile:
moke new [filename]
Which creates a skeleton file for you:
$ moke new Mokefile moke: *** Created /...path.../Mokefile moke: *** Running 'moke Mokefile --help'
Have fun!
Metadata
Release files for moke 1.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| moke-1.2.3.tar.gz | 209.4 kB | Without provenance | Details |
Release files / moke-1.2.3.tar.gz
| Download URL | moke-1.2.3.tar.gz |
|---|---|
| Size | 209.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5693b78bf8a6aa5b39a346d2c1023b45061ec2ffe458682ba9e3d9732fca1c38
|
|
BLAKE2b-256 checksum How to use checksums |
b36ab59169f0dce3871370bdcac8ff05a13b810beecc4e705356399c10752bbd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Security for moke 1.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.