-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
71 lines (70 loc) · 2.94 KB
/
Main.java
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
64
65
66
67
68
69
70
71
import java.util.Scanner;
import java.util.HashMap;
import java.util.Arrays;
public class Main {
public static void main(String[] args) throws Exception {
ConsoleTool console = new ConsoleTool(System.in, System.out, "Test Console\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
console.addCommand("test", new ConsoleTool.Command() {
public void execute(String... arguments) {
for(int i = 0; i < 1000; i++) {
console.Output("Test " + i);
console.ProgressBar(15, "Progress: ", i, 1000, " subtext");
}
}
});
console.addCommand("add", new ConsoleTool.Command() {
public void execute(String... arguments) {
if (arguments.length == 2) {
try {
int a = Integer.parseInt(arguments[0]);
int b = Integer.parseInt(arguments[1]);
console.Output(a + b);
} catch (NumberFormatException e) {
console.Output("Error: Invalid arguments");
}
} else {
console.Output("Error: Invalid arguments");
}
}
});
console.addCommand("sub", new ConsoleTool.Command() {
public void execute(String... arguments) {
if (arguments.length == 2) {
try {
int a = Integer.parseInt(arguments[0]);
int b = Integer.parseInt(arguments[1]);
console.Output(a - b);
} catch (NumberFormatException e) {
console.Output("Error: Invalid arguments");
}
} else {
console.Output("Error: Invalid arguments");
}
}
});
console.addCommand("clear", new ConsoleTool.Command() {
public void execute(String... arguments) {
console.Clear();
console.Output("Console cleared");
}
});
console.addCommand("help", new ConsoleTool.Command() {
public void execute(String... arguments) {
console.Output("Commands:");
console.Output("test - Test command");
console.Output("add <a> <b> - Add two numbers");
console.Output("sub <a> <b> - Subtract two numbers");
console.Output("help - Show this help message");
console.Output("clear - Clear the console");
console.Output("exit - Exit the console");
}
});
console.addCommand("exit", new ConsoleTool.Command() {
public void execute(String... arguments) {
console.finish();
System.exit(0);
}
});
console.start();
}
}