Skip to main content

A framework that facilitates shell and batch scripting in Python

Project description


BlazeCommandHelper (BCH) is a framework that facilitates the quick creation of shell and batch scripts. It provides a core command (bch) which locates sub-commands from system dirs, user dirs, and installed python packages (through the “blazech.commands” setuptools endpoint).

It also provides a library for quickly creating console applications based on the argparse parser.


  • locates plugin commands from various places

  • provides logging facilities

  • provides configuration file facilities (needs work)

The goal is to have an API that facilitates interaction between the environment, command line options, and configuration files ala pip.


Install BCH using easy_install or pip. Once installed, create a file for your first command:

# file location:
# *nix: ~/.blazech/
# windows: %APPDATA%\.blazech\

# file contents
from blazech.commands import BaseCommand

class Command(BaseCommand):
    name = 'hello-world'
    help = 'say hello'

    def create_arguments(self):
        #self.parser is the argparse parser for this sub-command
            '-n', '--name',
            help='who do you want to say hello to',

    def execute(self, args):
        print 'hello %s' %

to run:

# bch -h
usage: bch [-h] [-v] [-q] {hello-world} ...

positional arguments:
    hello-world     say hello

$ bch hello-world
hello world

$ bch hello-world -n foo
hello foo

Alternate Usage

BCH can also be used as a library to help quickly create commands line scripts:

        fooapp = foopackage.commands:script_entry

Run python develop (or install, etc.). Then, you will need:

# foopackage.commands
from blazech.application import Application
from blazech.commands import BaseCommand

def script_entry():
    app = Application('fooapp')
    # could also use
    # import foopackage.altcommands
    # app.load_commands(foopackage.altcommands)

class BarCommand(BaseCommand):
    name = 'bar'
    help = 'process bar file'

    def create_arguments(self):
        #self.parser is the argparse parser for this sub-command, see
        # argparser docs for usage
            help = 'path of the file to process',

    def execute(self, args):
        if args.fpath:
            print 'bar file is: %s' % args.fpath

You should then be able to:

$ fooapp -h
$ fooapp bar -h
$ fooapp bar ../my/bar/file.txt

Questions & Comments

Please visit:

Current Status

Primary use cases work for me, but b/c of time constraints will probably move forward slowly.

The development version is installable with easy_install BlazeCommandHelper==dev.


0.2.0 – 2011.04.29

  • feature: added support to be used as a library

  • bug: fixed some setup related bugs

  • bug: fix windows drive calculation

  • bug: reworked tests, all tests are now passing

Project details

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page