view memeomatic/main.py @ 0:bf637ccfcae5 default tip

initial stub
author Jeff Hammel <jhammel@mozilla.com>
date Wed, 04 Jul 2012 12:53:24 -0700
parents
children
line wrap: on
line source

#!/usr/bin/env python

"""
CLI meme generator
"""

import meme
import sys
import optparse

def main(args=sys.argv[:]):

    # parse command line options
    usage = '%prog [options] path/to/image.file'
    class PlainDescriptionFormatter(optparse.IndentedHelpFormatter):
        """description formatter for console script entry point"""
        def format_description(self, description):
            if description:
                return description.strip() + '\n'
            else:
                return ''
    parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter())
    parser.add_option('-h', '--header', dest='header',
                      help="text for the top of the image")
    parser.add_option('-f', '--footer', dest='footer',
                      help="text for the bottom of the image")
    parser.add_option('-o', '--output', dest='output',
                      help="output path for image")
    options, args = parser.parse_args(args)

    if len(args) != 1:
        parser.error("Please supply path to image")

    if not options.header and not options.footer:
        parser.error("Please supply --header and/or --footer text")



if __name__ == '__main__':
  main()