From 87c93f3ae025fe9f653fe7b15033142e7d8e3ace Mon Sep 17 00:00:00 2001 From: Niklas Kapelle Date: Sat, 17 Aug 2024 00:57:03 +0200 Subject: [PATCH] TurtleCtl times parameter optional --- src/bin/TurtleCtl.hx | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/bin/TurtleCtl.hx b/src/bin/TurtleCtl.hx index 111e94e..32c237a 100644 --- a/src/bin/TurtleCtl.hx +++ b/src/bin/TurtleCtl.hx @@ -12,28 +12,28 @@ using tink.CoreApi; class TurtleCtl extends CLIAppBase { public function new() { registerAsyncSubcommand("f", (args) -> { - return asynPerform(Turtle.forward, args.getInt("times")); - }, [Int("times")]); + return asynPerform(Turtle.forward, args.getInt("times") ?? 1); + }, [Optional(Int("times"))]); registerAsyncSubcommand("b", (args) -> { - return asynPerform(Turtle.back, args.getInt("times")); - }, [Int("times")]); + return asynPerform(Turtle.back, args.getInt("times") ?? 1); + }, [Optional(Int("times"))]); registerAsyncSubcommand("l", (args) -> { - return asynPerform(Turtle.turnLeft, args.getInt("times")); - }, [Int("times")]); + return asynPerform(Turtle.turnLeft, args.getInt("times") ?? 1); + }, [Optional(Int("times"))]); registerAsyncSubcommand("r", (args) -> { - return asynPerform(Turtle.turnRight, args.getInt("times")); - }, [Int("times")]); + return asynPerform(Turtle.turnRight, args.getInt("times") ?? 1); + }, [Optional(Int("times"))]); registerAsyncSubcommand("u", (args) -> { - return asynPerform(Turtle.up, args.getInt("times")); - }, [Int("times")]); + return asynPerform(Turtle.up, args.getInt("times") ?? 1); + }, [Optional(Int("times"))]); registerAsyncSubcommand("d", (args) -> { - return asynPerform(Turtle.down, args.getInt("times")); - }, [Int("times")]); + return asynPerform(Turtle.down, args.getInt("times") ?? 1); + }, [Optional(Int("times"))]); registerAsyncSubcommand("defrag", (args) -> { return asynPerform(() -> {