0
|
1 #!/usr/bin/env python
|
|
2
|
|
3 """
|
|
4 CLI meme generator
|
|
5 """
|
|
6
|
|
7 import meme
|
|
8 import sys
|
|
9 import optparse
|
|
10
|
|
11 def main(args=sys.argv[:]):
|
|
12
|
|
13 # parse command line options
|
|
14 usage = '%prog [options] path/to/image.file'
|
|
15 class PlainDescriptionFormatter(optparse.IndentedHelpFormatter):
|
|
16 """description formatter for console script entry point"""
|
|
17 def format_description(self, description):
|
|
18 if description:
|
|
19 return description.strip() + '\n'
|
|
20 else:
|
|
21 return ''
|
|
22 parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter())
|
|
23 parser.add_option('-h', '--header', dest='header',
|
|
24 help="text for the top of the image")
|
|
25 parser.add_option('-f', '--footer', dest='footer',
|
|
26 help="text for the bottom of the image")
|
|
27 parser.add_option('-o', '--output', dest='output',
|
|
28 help="output path for image")
|
|
29 options, args = parser.parse_args(args)
|
|
30
|
|
31 if len(args) != 1:
|
|
32 parser.error("Please supply path to image")
|
|
33
|
|
34 if not options.header and not options.footer:
|
|
35 parser.error("Please supply --header and/or --footer text")
|
|
36
|
|
37
|
|
38
|
|
39 if __name__ == '__main__':
|
|
40 main()
|
|
41
|