added turtle ctl dig command
This commit is contained in:
		
							parent
							
								
									09fef78f9a
								
							
						
					
					
						commit
						3e993b84eb
					
				| @ -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<Noise, String>, times:Int):Future<Bool> { | ||||
| @ -134,18 +148,4 @@ class TurtleCtl extends CLIAppBase { | ||||
| 			return null; | ||||
| 		}); | ||||
| 	} | ||||
| 
 | ||||
| 	private function parseTimes(args:Array<String>):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; | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user