monolith is an argparse based command line interface framework
Project description
Monolith
monolith is simple framwork for creating command line tools. Subcommands are class based (approach and part of implementation was inspired by Django management commands, however monolith uses argparse instead of optparse).
Supported Python versions are 2.6/2.7, 3.2+ and PyPy.
Latest documentation can be found at https://monolith.readthedocs.org/en/latest/.
Example
#!/usr/bin/env python """ Example of how to create git-like execution manager with monolith. This is completely fake command. """ from __future__ import print_function from monolith.cli import SimpleExecutionManager from monolith.cli import BaseCommand from monolith.cli import LabelCommand from monolith.cli import arg class AddCommand(LabelCommand): def handle_label(self, label, namespace): print("A %s" % label) class CommitCommand(BaseCommand): args = BaseCommand.args + [ arg('-a', '--add', action='store_true', default=False), arg('-m', '--message', help="Commit's message", required=True), ] def handle(self, namespace): print('Commit message: %r' % namespace.message) if namespace.add: print(' * add switch given!') def main(): manager = SimpleExecutionManager('mygit', commands={ 'add': AddCommand, 'commit': CommitCommand, }) manager.execute() if __name__ == '__main__': main()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
monolith-0.3.2.tar.gz
(12.1 kB
view details)
Built Distribution
File details
Details for the file monolith-0.3.2.tar.gz
.
File metadata
- Download URL: monolith-0.3.2.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26e0a67b366835d809f9c2e6940d477c49f0438e02a05fc229512fe8c8f1229b |
|
MD5 | 750e21bb1f79ce128848c72749ba1e70 |
|
BLAKE2b-256 | bed638bee5c0ffb8caa9f742bd755864c07d51f6d924137b70278a74b986d334 |
File details
Details for the file monolith-0.3.2-py2.py3-none-any.whl
.
File metadata
- Download URL: monolith-0.3.2-py2.py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d329c6eff41b2bc132fe38d70d2e74be6ca0729aac4d03970fcae0f8d1be2eb1 |
|
MD5 | 2a6ac80c221b052d26f07ba097fa9667 |
|
BLAKE2b-256 | 097aa41c710877943e804e2f3d15bf6bad5425d46193ce13f308b026ea05135b |