From: Phillip Berndt Date: Thu, 8 Jan 2015 08:55:36 +0000 (+0100) Subject: Python version: Option handling for unrecognized options X-Git-Tag: 1.0~112 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;ds=sidebyside;h=945889d272e204995a0eab006967089a683c4714;p=deb_pkgs%2Fautorandr.git Python version: Option handling for unrecognized options --- diff --git a/autorandr.py b/autorandr.py index 4c75f1d..7c12b5f 100755 --- a/autorandr.py +++ b/autorandr.py @@ -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")