]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/commitdiff
Improve usage information with GetoptError
authorDaniel Hahler <git@thequod.de>
Sun, 17 May 2015 15:47:59 +0000 (17:47 +0200)
committerDaniel Hahler <git@thequod.de>
Sun, 17 May 2015 15:47:59 +0000 (17:47 +0200)
 - print to stderr
 - do not display help automatically

autorandr.py

index f9e9f4c16d7347047f67aa94525f3d5f87eda645..285c751bda4294e4dd0e07846320d37c5deebd2f 100755 (executable)
@@ -37,6 +37,9 @@ from distutils.version import LooseVersion as Version
 from itertools import chain
 from collections import OrderedDict
 
+import posix
+
+
 virtual_profiles = [
     # (name, description, callback)
     ("common", "Clone all connected outputs at the largest common resolution", None),
@@ -606,8 +609,10 @@ def main(argv):
     try:
        options = dict(getopt.getopt(argv[1:], "s:l:d:cfh", [ "dry-run", "change", "default=", "save=", "load=", "force", "fingerprint", "config", "help" ])[0])
     except getopt.GetoptError as e:
-        print(str(e))
-        options = { "--help": True }
+        print("Failed to parse options: {0}.\n"
+              "Use --help to get usage information.".format(str(e)),
+              file=sys.stderr)
+        sys.exit(posix.EX_USAGE)
 
     profiles = {}
     try: