GitXplorerGitXplorer
p

argsrun

public
2 stars
0 forks
3 issues

Commits

List of commits on branch master.
Unverified
c545409a65d358b0ec45bcc166111ea4db6c519c

few tests added

ppopravich committed 9 years ago
Unverified
93b2ca055bfeecc840e55f160e1e350e5fea8269

Added docstring and made Entry callable

ppopravich committed 10 years ago
Unverified
d5d75d37ae13b353c767d420c43f737f1fbcd981

refactored public interface

ppopravich committed 10 years ago
Unverified
8995f76fa7eef8418a665dbce6b7772ec5224f76

.gitignore added

ppopravich committed 10 years ago
Unverified
f9e35a45048be0e05e5337d7c91252303448b369

exception added

ppopravich committed 10 years ago
Unverified
67b9ad1f8ac1095468dbcd9dfbcf6cdfe13df99e

readme added

ppopravich committed 10 years ago

README

The README file for this repository.

Argsrun

Simple tool for creating pluggable commands and sub-commands.

Usage example:

.. code:: python

# in setup.py of your project specify argsrun entry point in console scripts
# and provided commands as follows:

setup(name="MyProj",
      # ...
      entry_points={
        'console_scripts': [
            'myproj = argsrun:main',  # argsrun will handle main command
        ],
        'myproj': [                   # ...and lookup for this subcommands
            'main = myproj:main',
            'run = myproj.module:run',
        ],
      })

In case you have several packages/projects and you want them to share same entry point, you can easily do it like follows:

.. code:: python

# my-frontend-app/setup.py

setup(name="MySite Frontend",
      entry_points={
        'console_scripts': [
            'mysite = argsrun:main',
        ],
        'mysite': [
            'serve-frontend = frontend:serve',
        ]
      })

# my-backend-app/setup.py

setup(name="MySite Admin backend",
      entry_points={
        'console_scripts': [
            'mysite = argsrun:main',
        ],
        'mysite': [
            'serve-admin = backend:serve',
        ]
      })

 # In my-frontend-app/frontend/__init__.py

 import argsrun

 def handler(options):
     # Run frontend app
     pass

 def parser_setup(ap):
     ap.add_argument('--port', help="Port to bind to")

 main = argsrun.Entry(handler, parser_setup)