Skip to main content

Framework for creating CLI apps using Python

Project description

Python CLI App

Framework for creating CLI apps using Python

The purpose of this library is to speed up bulding CLI applications by providing abstract classes representing an app and its commands. It uses argparse to define and parse command line arguments.



An "App" is the main entry point of an application. It groups together one or more commands


A "Command" is a single operation that the application can perform. It is identified by a positional argument on the command line. Let's take git as an example. git would be the app that provides different commands, such as add, commit, merge, checkout, etc.


#!/usr/bin/env python3

from cli_app import App
from commands.checkout import Checkout
from commands.merge import Merge

class Git(App):
    """Git - fast, scalable, distributed revision control system"""

    def register_commands(self):
        self.add_command('checkout', Checkout)  # make the Checkout command available through ` checkout …`
        self.add_command('merge', Merge)  # make the Merge command available through ` merge …`

if __name__ == '__main__':
    app = Git()


from cli_app import Command

class Checkout(Command):
    """Switch branches or restore working tree files"""

    def register_arguments(parser):
        parser.add_argument('ref', type=str, help='The ref (branch name, tag, commit sha) to checkout')

    def run(self):
        # Do whatever needs to be done to checkout given ref
        print('Checking out %s' %


from cli_app import Command

class Merge(Command):
    """Join two or more development histories together"""

    def register_arguments(parser):
        parser.add_argument('branch', type=str, help='The branch to merge into the currently checked-out branch')

    def run(self):
        # Do whatever needs to be done to merge given branch
        print('Merging %s into current branch' %

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for cli-app, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size cli_app-0.1.0-py3-none-any.whl (5.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size cli-app-0.1.0.tar.gz (3.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page