Skip to content

Commit

Permalink
build: sort.py: support "--" and fail on unknown option
Browse files Browse the repository at this point in the history
Support "--" to end options and fail if an unknown option is given.
  • Loading branch information
kmk3 committed May 13, 2024
1 parent b177ec0 commit a6d2119
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion contrib/sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
__doc__ = f"""\
Sort the arguments of commands in profiles.
Usage: {path.basename(argv[0])} [-i] [-n] [/path/to/profile ...]
Usage: {path.basename(argv[0])} [-i] [-n] [--] [/path/to/profile ...]
The following commands are supported:
Expand All @@ -23,6 +23,7 @@
Options:
-i Edit the profile file(s) in-place (this is the default).
-n Do not edit the profile file(s) in-place.
-- End of options
Examples:
$ {argv[0]} MyAwesomeProfile.profile
Expand Down Expand Up @@ -110,6 +111,12 @@ def main(args):
elif args[0] == "-n":
overwrite = False
args.pop(0)
elif args[0] == "--":
args.pop(0)
break
elif args[0][0] == "-":
print(f"[ Error ] Unknown option: {args[0]}", file=stderr)
return 2
else:
break

Expand Down

0 comments on commit a6d2119

Please sign in to comment.