argparse: Create a command-line app with Python

argparse is a Python standard library makes it easy to write a CLI application. You should use this module instead of optparse.

ref:
https://docs.python.org/2.7/library/argparse.html

import argparse

class HAL9000Formatter(argparse.HelpFormatter):

    def __init__(self, prog):
        super(HAL9000Formatter, self).__init__(prog, max_help_position=30)

class HAL9000(object):

    def __init__(self):
        parser = argparse.ArgumentParser(
            prog='hal',
            description='I am completely operational, and all my circuits are functioning perfectly',
            version='9000',
            formatter_class=HAL9000Formatter
        )
        self.parser = parser

        subparsers = parser.add_subparsers(
            title='sub commands'
        )

        update_parser = subparsers.add_parser('update', help='pull the repo and run ansible-playbook')
        update_parser.set_defaults(func=self.update)

    def update(self, namespace, extra_args=None):
        do_shit()