summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Waltman <jonathan.waltman@gmail.com>2013-01-04 22:48:21 -0600
committerJonathan Waltman <jonathan.waltman@gmail.com>2013-01-04 22:48:21 -0600
commitf1db8a371db569a557380d28ba2f63fe7b67b8a2 (patch)
treefdd8fe583bf098f0b98f70327bc9573740e5a460
parentc0a85dc40be3b8bbd997a9430087f73c3ebdce4e (diff)
downloadsphinx-f1db8a371db569a557380d28ba2f63fe7b67b8a2.tar.gz
sphinx-build: Support the standard ``--help`` and ``--version`` options.
-rw-r--r--CHANGES3
-rw-r--r--sphinx/cmdline.py11
2 files changed, 13 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index 67c8155b..5f5ab76d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
Release 1.2 (in development)
============================
+* sphinx-build now supports the standard :option:`--help` and
+ :option:`--version` options.
+
* #869: sphinx-build now has the option :option:`-T` for printing the full
traceback after an unhandled exception.
diff --git a/sphinx/cmdline.py b/sphinx/cmdline.py
index 9b8d8ae2..026bcd45 100644
--- a/sphinx/cmdline.py
+++ b/sphinx/cmdline.py
@@ -60,6 +60,8 @@ new and changed files
-W -- turn warnings into errors
-P -- run Pdb on exception
-T -- show full traceback on exception
+ --help -- show this help and exit
+ --version -- show version information and exit
Modi:
* without -a and without filenames, write new and changed files.
* with -a, write all files.
@@ -72,8 +74,15 @@ def main(argv):
nocolor()
try:
- opts, args = getopt.getopt(argv[1:], 'ab:t:d:c:CD:A:ng:NEqQWw:PT')
+ opts, args = getopt.getopt(argv[1:], 'ab:t:d:c:CD:A:ng:NEqQWw:PTh',
+ ['help', 'version'])
allopts = set(opt[0] for opt in opts)
+ if '-h' in allopts or '--help' in allopts:
+ usage(argv)
+ return 0
+ if '--version' in allopts:
+ print 'Sphinx (sphinx-build) %s' % __version__
+ return 0
srcdir = confdir = abspath(args[0])
if not path.isdir(srcdir):
print >>sys.stderr, 'Error: Cannot find source directory `%s\'.' % (