Skip to main content

monolith is an argparse based command line interface framework

Project description

https://secure.travis-ci.org/lukaszb/monolith.png?branch=master

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.3.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

monolith-0.3.3-py2.py3-none-any.whl (29.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file monolith-0.3.3.tar.gz.

File metadata

  • Download URL: monolith-0.3.3.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for monolith-0.3.3.tar.gz
Algorithm Hash digest
SHA256 b4b666401f0b3bb7f460bae63c065d36a926c2493e87cfcedc20a60a2b29463e
MD5 41d1671755f0bbcfdb858dc33f1ac0b7
BLAKE2b-256 3b0af26901f3ed94bd142856255a8ae0e2d701116a913f8349b5bf21d3d068fe

See more details on using hashes here.

Provenance

File details

Details for the file monolith-0.3.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for monolith-0.3.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 421a0492fa3b58c45d4b87dcc046737f32fbc6a4d872ae84a0f8dd522b9d430a
MD5 6981707b90aacf751d2287cfeb6c869c
BLAKE2b-256 d5b049fed09aae1b38baf46257a755cf550bb607851dc096042116758de54a39

See more details on using hashes here.

Provenance

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