Skip to main content

The intenetion

ec - intends to reduce the learning curve needed to expose functionality via the command line. With available options like argparse and docopt, it might take several hours to get them right. And there is also the issue of the needed amount of extra coding to setup and process the arguments. See the following example to see how ec solves the issue.

A simple example

from ec.ec import task

@task
def say_hello():
        print 'Hello, world!'

could be accessed from the command line, like:

$ python hello.py say_hello
        Hello, world!

Features

  • Typed arguments.

  • Sub commands (like git).

  • Custom types.

  • Shell mode (like python’s interactive mode).

  • Named / Positional arguments.

A more complete example

from: simple.py

from ec.ec import task, arg, group

@task # define a task
@arg(type=int, desc= 'Value for arg1') # add an argument with a type and a description
@arg(type=int)
def task1(arg1, arg2=1):
        print arg1, arg2

@group(desc = 'A group with some tasks') # define a group
class group1:
        @task
        def task1(arg1): # define a task inside the group
                print arg1 + arg1

Execute a task: <dispatch mode>

From the command-line enter

$ python simple.py task1 arg1=1 arg2=2
        1 2

$ python simple.py group1/task1 arg1=1
        2

$ python simple.py group1/task1 1 # positional arguments too are supported
        2

Interactively execute tasks: <shell mode>

From the command-line enter

$ python simple.py # this will enter into ec-shell

>task1
Value for arg1: 1
arg2 (1): 2
1 2

>group1/task1 # execute task1 under group1
arg1: 1
11

>task1 arg1=1 # arguments can be given while calling the task, the missing arguments will be collected from the user
arg2 (1): 2
1 2

>^Z # exit the shell

Utilizing STDIN:

From the command-line enter

$ echo 1 2 | xargs python simple.py task1 # Dispatch a command with args passed through STDIN and converted to args using xargs.
$ echo -e "1\n2" | python simple.py -p task1 # Dispatch a command and with partial args and pass the rest through STDIN.
$ echo task1 1 2 | python simple.py # Feeding the shell with complete commands through stdin.

Detailed docs could be found at PyDocs.

For more examples check the github page.

Release files for ec 0.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ec 0.2.5
File Size Uploaded
ec-0.2.5.tar.gz 39.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ec 0.2.5
File Interpreter ABI Platform
ec-0.2.5-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 65.7 kB

Release files / ec-0.2.5.tar.gz

Download URL ec-0.2.5.tar.gz
Size 39.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7f2e139b30ed6e97c6d651fb0d2d37a0c167c0ac2b355b4de366e35d9b88f839
BLAKE2b-256 checksum
How to use checksums
1e701073ffed8ac9126a30afbaba3074ac69ee6c63e19974f7ad7f8657a7ac54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15

Release files / ec-0.2.5-py2.py3-none-any.whl

Download URL ec-0.2.5-py2.py3-none-any.whl
Size 26.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
ff3cb93c0af77506ad3d5dfb91732cbde3971e4d69a73bd66b70d2e5afebb959
BLAKE2b-256 checksum
How to use checksums
209e4d4a8d1e4274aeebd75c262a5e3917333cd6f9d3deb489ec6ccf679672a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15

Release history Release notifications | RSS feed

This release

0.2.5 This release

2 release files

0.2.4

2 release files

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page