added terminal app with example hello world
This commit is contained in:
6
src/lib/CLIBase.hx
Normal file
6
src/lib/CLIBase.hx
Normal file
@@ -0,0 +1,6 @@
|
||||
package lib;
|
||||
|
||||
abstract class CLIBase {
|
||||
public function new() {};
|
||||
public abstract function invoke(handle: TermHandle): Bool;
|
||||
}
|
||||
29
src/lib/TermHandle.hx
Normal file
29
src/lib/TermHandle.hx
Normal file
@@ -0,0 +1,29 @@
|
||||
package lib;
|
||||
|
||||
import haxe.ds.ReadOnlyArray;
|
||||
|
||||
typedef TermHandleEvents = {
|
||||
onWrite: String->Void,
|
||||
onNewLine: Void->Void,
|
||||
}
|
||||
|
||||
class TermHandle {
|
||||
public final args:ReadOnlyArray<String>;
|
||||
private final events:TermHandleEvents;
|
||||
|
||||
@:allow(bin.Terminal)
|
||||
private function new(args: Array<String>, events: TermHandleEvents) {
|
||||
this.args = args;
|
||||
this.events = events;
|
||||
}
|
||||
|
||||
public function write(s:String) {
|
||||
this.events.onWrite(s);
|
||||
}
|
||||
|
||||
public function writeLn(s:String = "") {
|
||||
if (s != "")
|
||||
this.events.onWrite(s);
|
||||
this.events.onNewLine();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user