monolith 是一个基于 argparse 的命令行界面框架
项目描述
Monolith
monolith 是一个简单的用于创建命令行工具的框架。子命令是基于类(实现方式和部分灵感来自 Django 管理命令,但 monolith 使用 argparse 而不是 optparse)。
支持的 Python 版本是 2.6/2.7, 3.2+ 和 PyPy。
最新文档可以在 https://monolith.readthedocs.org/en/latest/ 找到。
示例
#!/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()
项目详情
下载文件
为您的平台下载文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。
源代码分发
monolith-0.3.3.tar.gz (12.1 kB 查看哈希)
构建分发
monolith-0.3.3-py2.py3-none-any.whl (29.6 kB 查看哈希)