forked from Whiteknight/Rosella
/
winxed_repl.winxed
63 lines (55 loc) · 1.52 KB
/
winxed_repl.winxed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
function main[main](var args)
{
//using Rosella.get_version_hash;
//var version_hash = get_version_hash();
//for (string library in version_hash)
//load_bytecode("rosella/" + library + ".pbc");
show_preamble();
// TODO: Use CommandLine library to parse args.
if (elements(args) <= 1)
run_repl();
else if (args[1] == "--help")
show_help();
else if (args[1] == "--version")
show_versions();
else
say("Unknown arguments");
}
function show_help()
{
say(<<:
Winxed/Rosella REPL
--help Show this help
--version Show version information
:>>
);
}
function show_versions()
{
// TODO: Show the Winxed compiler version, or versions of any other compilers
// loaded
// TODO: When the String library gets more stable, use this for prettiness
//using Rosella.String.pad_right;
var version_hash = Rosella.Version.get_version_hash();
say("Rosella library version information:");
for (string library in version_hash) {
var ver = Rosella.Version.get_version(library);
//library = pad_right(library, 10);
Rosella.IO.sayf("\t%s : %d (%s)", library, ver.version_number, ver.state);
}
}
function show_preamble()
{
var winxed_version = Rosella.Version.get_version("repl");
Rosella.IO.sayf(<<:
Winxed REPL with Rosella
Version %d %s
Type '%%quit' or 'exit(0)' to quit
:>>
, winxed_version.version_number, winxed_version.state);
}
function run_repl()
{
var repl = new Rosella.Repl();
repl.run_loop();
}