Skip to content

Commit b87aaea

Browse files
committed
Merge pull request wertarbyte#31 from blueyed/improve-usage-error
Improve usage information with GetoptError
2 parents 8b9eb29 + 36b7e2a commit b87aaea

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

autorandr.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
from itertools import chain
3939
from collections import OrderedDict
4040

41+
import posix
42+
43+
4144
virtual_profiles = [
4245
# (name, description, callback)
4346
("common", "Clone all connected outputs at the largest common resolution", None),
@@ -611,8 +614,10 @@ def main(argv):
611614
try:
612615
options = dict(getopt.getopt(argv[1:], "s:l:d:cfh", [ "dry-run", "change", "default=", "save=", "load=", "force", "fingerprint", "config", "help" ])[0])
613616
except getopt.GetoptError as e:
614-
print(str(e))
615-
options = { "--help": True }
617+
print("Failed to parse options: {0}.\n"
618+
"Use --help to get usage information.".format(str(e)),
619+
file=sys.stderr)
620+
sys.exit(posix.EX_USAGE)
616621

617622
profiles = {}
618623
try:

0 commit comments

Comments
 (0)