Commits

Jon Waltman committed a7cdcb4

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

Comments (0)

Files changed (2)

 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.
 

sphinx/cmdline.py

         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
             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':