summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-05-29 18:58:17 +0300
committerLars Wirzenius <liw@liw.fi>2021-05-29 18:58:17 +0300
commit5e107a17bc0f46a77dc6a8d74021472f8baeff02 (patch)
treea20421d189e171365740ea5bb8566933a78b7e90
parent19fd3032fc36cce09be4db89fc6580f7e124bb63 (diff)
downloadoso-work-sample-5e107a17bc0f46a77dc6a8d74021472f8baeff02.tar.gz
feat: allow user to specify op, numbers for max-client.py
Sponsored-by: author
-rw-r--r--max-client.py18
1 files 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)