diff --git a/src/bin/TurtleCtl.hx b/src/bin/TurtleCtl.hx index 46b30da..4dd8a0c 100644 --- a/src/bin/TurtleCtl.hx +++ b/src/bin/TurtleCtl.hx @@ -96,6 +96,20 @@ class TurtleCtl extends CLIAppBase { return Success(null); }, 1); }, [Optional(String("to"))]); + + registerAsyncSubcommand("dig", (args) -> { + var direction = args.getString("direction"); + switch (direction) { + case "front" | "f": + return asynPerform(() -> Turtle.dig(Front), 1); + case "top" | "t" | "up" | "u": + return asynPerform(() -> Turtle.dig(Up), 1); + case "bot" | "bottom" | "b" | "down" | "d": + return asynPerform(() -> Turtle.dig(Down), 1); + default: + return Future.sync(false); + } + }, [String("direction")]); } private function asynPerform(op:Void->Outcome, times:Int):Future { @@ -134,18 +148,4 @@ class TurtleCtl extends CLIAppBase { return null; }); } - - private function parseTimes(args:Array):Int { - if (args.length > 0) { - var num = Std.parseInt(args[0]); - if (num == null) { - handle.writeLine("Failed to parse args"); - return 0; - } else { - return num; - } - } else { - return 1; - } - } }