sphinx-build: Provide more specific error messages for invalid arguments.

This commit is contained in:
Jonathan Waltman
2013-01-04 22:52:42 -06:00
parent 66fe7cc2d7
commit 3cd00a0809
2 changed files with 10 additions and 4 deletions

View File

@@ -1,6 +1,9 @@
Release 1.2 (in development)
============================
* sphinx-build now provides more specific error messages when called with
invalid options or arguments.
* sphinx-build now supports the standard :option:`--help` and
:option:`--version` options.

View File

@@ -97,15 +97,18 @@ def main(argv):
if not path.isdir(outdir):
print >>sys.stderr, 'Making output directory...'
os.makedirs(outdir)
except (IndexError, getopt.error):
usage(argv)
except getopt.error, err:
usage(argv, 'Error: %s' % err)
return 1
except IndexError:
usage(argv, 'Error: Insufficient arguments.')
return 1
filenames = args[2:]
err = 0
for filename in filenames:
if not path.isfile(filename):
print >>sys.stderr, 'Cannot find file %r.' % filename
print >>sys.stderr, 'Error: Cannot find file %r.' % filename
err = 1
if err:
return 1
@@ -132,7 +135,7 @@ def main(argv):
buildername = val
elif opt == '-a':
if filenames:
usage(argv, 'Cannot combine -a option and filenames.')
usage(argv, 'Error: Cannot combine -a option and filenames.')
return 1
force_all = True
elif opt == '-t':