CLI main
This commit is contained in:
28
hank/Main.hx
Normal file
28
hank/Main.hx
Normal file
@@ -0,0 +1,28 @@
|
||||
package hank;
|
||||
|
||||
import sys.FileSystem;
|
||||
import hank.Story;
|
||||
|
||||
class Main {
|
||||
static function main() {
|
||||
var args = Sys.args();
|
||||
|
||||
for (arg in args) {
|
||||
if (FileSystem.exists(arg) && !FileSystem.isDirectory(arg)) {
|
||||
Sys.println(arg);
|
||||
Story.FromFile(arg).run((text, cc) -> {
|
||||
Sys.println(text);
|
||||
cc();
|
||||
}, (choices, choose) -> {
|
||||
for (idx in 0...choices.length) {
|
||||
Sys.println('${idx+1}. ${choices[idx]}');
|
||||
}
|
||||
var choiceIndex = Std.parseInt(Sys.stdin().readLine()) - 1;
|
||||
choose(choiceIndex);
|
||||
}, () -> {
|
||||
Sys.println("THE END");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
"version": "0.0.8",
|
||||
"releasenote": "It isn't safe to use this library yet.",
|
||||
"contributors": ["NQNStudios"],
|
||||
"main": "hank.Main",
|
||||
"dependencies": {
|
||||
"hscript": "",
|
||||
"utest": ""
|
||||
|
||||
Reference in New Issue
Block a user