From: W. Trevor King Date: Thu, 14 Aug 2014 23:18:42 +0000 (-0700) Subject: gallery.py: Add a 'version' argument X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0dd1e1f1df0335e70dc78b49e76edd1bea2dad53;p=blog.git gallery.py: Add a 'version' argument With the 'version' action [1], instead of passing the version as an argument to ArgumentParser (which was at one point supported in Python, but I can't find the deprecation docs). [1]: https://docs.python.org/3/library/argparse.html#action [2]: https://docs.python.org/3/library/argparse.html#argparse.ArgumentParser --- diff --git a/posts/gallery/gallery.py b/posts/gallery/gallery.py index 3b3ed1d..760768f 100755 --- a/posts/gallery/gallery.py +++ b/posts/gallery/gallery.py @@ -827,8 +827,11 @@ if __name__ == '__main__': import argparse as _argparse parser = _argparse.ArgumentParser( - description=__doc__, version=__version__, + description=__doc__, formatter_class=_argparse.RawDescriptionHelpFormatter) + parser.add_argument( + '--version', action='version', + version='%(prog)s {}'.format(__version__)) parser.add_argument( '--mode', default='cgi', choices=['cgi', 'scgi', 'wsgi'], help='Server mode (defaults to CGI)')