]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/commitdiff
Python version: Option handling for unrecognized options
authorPhillip Berndt <phillip.berndt@googlemail.com>
Thu, 8 Jan 2015 08:55:36 +0000 (09:55 +0100)
committerPhillip Berndt <phillip.berndt@googlemail.com>
Thu, 8 Jan 2015 08:55:36 +0000 (09:55 +0100)
autorandr.py

index 4c75f1d27fe07a9506f2944b4747f778c9202fc5..7c12b5fc0cf981d171dca047cab082bc4dbfe45d 100755 (executable)
@@ -416,7 +416,11 @@ def exec_scripts(profile_path, script_name):
             subprocess.call(script)
 
 def main(argv):
-    options = dict(getopt.getopt(argv[1:], "s:l:d:cfh", [ "dry-run", "change", "default=", "save=", "load=", "force", "fingerprint", "config", "help" ])[0])
+    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 }
 
     profile_path = os.path.expanduser("~/.autorandr")