From 5e107a17bc0f46a77dc6a8d74021472f8baeff02 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 29 May 2021 18:58:17 +0300 Subject: feat: allow user to specify op, numbers for max-client.py Sponsored-by: author --- max-client.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/max-client.py b/max-client.py index 488fc6b..1439977 100644 --- a/max-client.py +++ b/max-client.py @@ -93,8 +93,22 @@ if __name__ == "__main__": required=False, help="address of the max computer (defaults to http://localhost:5000)", ) + parser.add_argument( + "--compute", + metavar="OP", + type=str, + choices=("max", "min"), + help="what operation to compute on the numbers? max or min", + ) + parser.add_argument( + "numbers", + metavar="N", + type=int, + nargs="+", + help="numbers for list to query, in order", + ) args = parser.parse_args() client = Client(args.address, log=True) - assert 3 == client.compute([1, 2, 3, 1], op="max") - assert 1 == client.compute([1, 2, 3, 1], op="min") + answer = client.compute(args.numbers, op=args.compute) + print(answer) -- cgit v1.2.1