summaryrefslogtreecommitdiff
path: root/dice-lang
diff options
context:
space:
mode:
authorEVE <EVE@EVE-PC>2017-03-14 12:20:59 -0400
committerEVE <EVE@EVE-PC>2017-03-14 12:20:59 -0400
commitfbfea4c79027e4f24bcaeca5c5fb77a432a0f06e (patch)
treece4d0fe2d23f3e7d15be144440bd78d1b10e75fc /dice-lang
parent635d3150e3e85c01b777ff165e21fa8965d58440 (diff)
Implement CLI arg help.
Diffstat (limited to 'dice-lang')
-rw-r--r--dice-lang/data/help/cli.help3
-rw-r--r--dice-lang/src/bjc/dicelang/CLIArgsParser.java27
-rw-r--r--dice-lang/src/bjc/dicelang/util/ResourceLoader.java4
3 files changed, 11 insertions, 23 deletions
diff --git a/dice-lang/data/help/cli.help b/dice-lang/data/help/cli.help
index b517d32..3ac6145 100644
--- a/dice-lang/data/help/cli.help
+++ b/dice-lang/data/help/cli.help
@@ -1,4 +1,7 @@
Help for DiceLang v0.2 CLI arguments:
+ -h or --help Show help
+ Shows this help message
+
-d or --debug Turn on debug mode.
Turns on debug mode, which prints additional information that
may be useful for finding errors.
diff --git a/dice-lang/src/bjc/dicelang/CLIArgsParser.java b/dice-lang/src/bjc/dicelang/CLIArgsParser.java
index 6b96ac6..4ecb91b 100644
--- a/dice-lang/src/bjc/dicelang/CLIArgsParser.java
+++ b/dice-lang/src/bjc/dicelang/CLIArgsParser.java
@@ -1,5 +1,7 @@
package bjc.dicelang;
+import bjc.dicelang.util.ResourceLoader;
+
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -29,27 +31,10 @@ public class CLIArgsParser {
if(args.length < 0) return true;
if(args.length == 1 && (args[0].equals("--help") || args[0].equals("-h"))) {
- System.out.println("Help for DiceLang v0.2 CLI arguments:");
- System.out.println("\t-d or --debug\tTurn on debug mode.");
- System.out.println(
- "\t\tTurns on debug mode, which prints additional information that may be useful.");
- System.out.println("\t-nd or --no-debug\tTurn off debug mode.");
- System.out.println("\t\tTurns off debug mode.");
- System.out.println("\t-po or --postfix\tTurn on postfix mode.");
- System.out.println("\t\tTurns on postfix mode, which disables the shunter.");
- System.out.println("\t-npo or --no-postfix\tTurn off postfix mode.");
- System.out.println("\t\tTurns off postfix mode.");
- System.out.println("\t-pr or --prefix\tTurn on prefix mode.");
- System.out.println(
- "\t\tTurns on prefix mode, which reverses the expression instead of shunting it.");
- System.out.println("\t-npr or --no-prefix\tTurn off prefix mode.");
- System.out.println("\t\tTurns off prefix mode.");
- System.out.println("\t-se or --step-eval\tTurn on step-eval mode.");
- System.out.println(
- "\t\tTurns on step-evaluation, which shows the evaluation process step-by-step. Currently slightly broken.");
- System.out.println("\t-nse or --no-step-eval\tTurn off step-eval mode.");
- System.out.println("\t\tTurns off step-evaluation.");
- System.out.println("\t-D or ");
+ for(String lne : ResourceLoader.loadHelpFile("cli")) {
+ System.out.println(lne);
+ }
+
System.exit(0);
}
diff --git a/dice-lang/src/bjc/dicelang/util/ResourceLoader.java b/dice-lang/src/bjc/dicelang/util/ResourceLoader.java
index 65dc1e4..c8561dc 100644
--- a/dice-lang/src/bjc/dicelang/util/ResourceLoader.java
+++ b/dice-lang/src/bjc/dicelang/util/ResourceLoader.java
@@ -26,8 +26,8 @@ public class ResourceLoader {
* @return The contents of the help file, or null if it could not be
* opened
*/
- public String[] loadHelpFile(String name) {
- URL fle = this.getClass().getResource("/data/help/" + name + ".help");
+ public static String[] loadHelpFile(String name) {
+ URL fle = ResourceLoader.class.getResource("/data/help/" + name + ".help");
try {
return Files.lines(Paths.get(fle.toURI())).toArray(sze -> new String[sze]);