Skip to content

Commit

Permalink
Return a better error if you forget to add the subcommand
Browse files Browse the repository at this point in the history
before it would just throw and exception. Now it complains that no command
was found and says the only valid one is {'push-to-quay'}
  • Loading branch information
eparis committed Feb 17, 2020
1 parent a88e2ca commit 853eef5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions hack/graph-util.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ def get_token(args):

if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Utilities for managing graph data.')
subparsers = parser.add_subparsers()
subparsers = parser.add_subparsers(dest='command')

push_to_quay_parser = subparsers.add_parser(
'push-to-quay',
Expand All @@ -489,10 +489,11 @@ def get_token(args):
'--versions',
help='Comma Seperated Versions to sync',
)
push_to_quay_parser.set_defaults(action='push-to-quay')

args = parser.parse_args()

token = get_token(args=args)
if args.action == 'push-to-quay':
if args.command == 'push-to-quay':
token = get_token(args=args)
push(directory='.', token=token, push_versions=args.versions)
else:
parser.print_usage()

0 comments on commit 853eef5

Please sign in to comment.