Skip to content

Commit

Permalink
Improve CLI arg parsing error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
lopopolo committed Sep 4, 2022
1 parent fd6937d commit af69af0
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion macos_sign_and_notarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ def validate(*, bundle, binary_names):

def main(args):
if not args:
print("Error: pass binaries to sign as positional arguments", file=sys.stderr)
print("Error: pass name of release as first argument", file=sys.stderr)
return 1

release_name, *args = args
Expand All @@ -603,9 +603,21 @@ def main(args):
append_next = resources
continue
print(f"Unexpected argument: {arg}", file=sys.stderr)
return 1
append_next.append(Path(arg))
append_next = None

if append_next is not None:
if append_next is binaries:
print("Error: unterminated --binary flag", file=sys.stderr)
if append_next is resources:
print("Error: unterminated --resource flag", file=sys.stderr)
return 1

if not binaries:
print("Error: no binaries passed to be codesigned", file=sys.stderr)
return 1

for binary in binaries:
if not binary.is_file():
print("Error: {binary} does not exist", file=sys.stderr)
Expand Down

0 comments on commit af69af0

Please sign in to comment.