From fe17b4fd679478ac08c38c8b093af497e615df69 Mon Sep 17 00:00:00 2001 From: Niklas Kapelle Date: Sun, 20 Oct 2024 23:23:58 +0200 Subject: [PATCH] added inspect command to turtleCtl --- src/bin/TurtleCtl.hx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/bin/TurtleCtl.hx b/src/bin/TurtleCtl.hx index 32c237a..25733b8 100644 --- a/src/bin/TurtleCtl.hx +++ b/src/bin/TurtleCtl.hx @@ -1,5 +1,6 @@ package bin; +import kernel.turtle.Types.ToolSide; import lib.turtle.Helper; import kernel.turtle.TurtleMutex; import kernel.turtle.Turtle; @@ -116,6 +117,28 @@ class TurtleCtl extends CLIAppBase { var len = args.getInt("length"); return asynPerform(Helper.combine.bind([Turtle.digEmpty.bind(Front), Turtle.forward, Turtle.digEmpty.bind(Up)]), len); }, [Int("length")]); + + registerSyncSubcommand("inspect", (args) -> { + var res = Turtle.inspect(Front); + + switch res { + case Failure(err): + handle.writeLine("Failed: " + err); + return false; + case Success(data): + handle.writeLine('Name: ${data.name}'); + handle.writeLine("Tags:"); + + for (tag in data.tags.sortByName()) { + handle.writeLine(' ${tag}'); + } + + handle.writeLine("State:"); + handle.writeLine(data.state); + } + + return true; + }, []); } private function asynPerform(op:Void->Outcome, times:Int):Future {