A Better Way To Write Linux Command Line Applications with Python
drks — Thu, 2009-12-17 02:41
I've spent the last week or so working on a new project to standardize how I write Linux command line applications, and also make it easier to reuse helper code and plugins. The result is the Cement CLI Application Framework for Python.
Cement is a CLI Application Framework for Python. It promotes code re-use by
way of plugins and helper libraries that can be maintained internally, or
shared with the community. For a solid development base, build your next cli
on cement!
At a minimum, Cement easily sets up the following:
Configuration file parsing [using ConfigObj]
Command line arguments and option parsing [using OptParse]
Logging [using Logger]
Plugin support [partially using setuptools]
Basic "hook" support
These pieces are important for a fully functional command line application.
Normally to accomplish what's listed above would require dozens of lines of
work before you even begin coding your application. With Cement, the above is
configured with more or less a single command (via paste).
Cement is most generally used as a starting point from which to begin
developing a command line type application. That said, applications using
cement can also share plugins with either cement or other applications using
cement.
GETTING STARTED:
Stable versions of Cement can be installed via the cheeze shop:
$ easy_install cement
Development versions of Cement can be checked out of Git:
$ git clone git://github.com/derks/cement.git
$ cd cement
$ python setup.py install
Additionally, Cement applications, plugins, and helpers can be created via
PasteScript. Once Cement is installed, the following command will create a
command line application built on top of the Cement Framework:
$ paster cement-app <myapp>
The following command will create an external plugin for your application:
$ paster cement-plugin <myapp> <myplugin>
Have a helper library you want to make plugable?
$ paster cement-helper <myapp> <myhelper>The Cement Framework is Open Source, and licensed under the Python Software Foundation License. I'm going to continue working not only on the code, but solidifying all the documentation for it. That said, I've just finished a 2 hour brain dump on Developing with Cement on the wiki and thought it would be worth mentioning here.
One of the goals of Cement is plugin re-use, and hope to have a long list of available plugins that can be dropped right into any application. Check it out, and let me know what you think!
RSS Feed
Post new comment