From 0dd1e1f1df0335e70dc78b49e76edd1bea2dad53 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 14 Aug 2014 16:18:42 -0700 Subject: [PATCH] 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 --- posts/gallery/gallery.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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)') -- 2.26.2