From f98489186ec80064bbbcd131238127e909f80a06 Mon Sep 17 00:00:00 2001
From: spasskopf <78727783+spasskopf@users.noreply.github.com>
Date: Tue, 13 Apr 2021 13:50:18 +0200
Subject: [PATCH] Added -help option
---
.../dimensionfinder/DimensionFinder.java | 58 ++++++++++++++++---
1 file changed, 50 insertions(+), 8 deletions(-)
diff --git a/src/main/java/me/spasskopf/dimensionfinder/DimensionFinder.java b/src/main/java/me/spasskopf/dimensionfinder/DimensionFinder.java
index 4d5dfcb..5861ecf 100644
--- a/src/main/java/me/spasskopf/dimensionfinder/DimensionFinder.java
+++ b/src/main/java/me/spasskopf/dimensionfinder/DimensionFinder.java
@@ -17,6 +17,34 @@
* Main class
*/
public class DimensionFinder {
+
+ /**
+ * Help text
+ */
+ public static final String HELP_TEXT = """
+ Available Options:
+ -threads={num}
+ required: yes
+ Number of Threads you want to use
+ example: -threads=16
+
+ -length={num}
+ required: yes
+ Length of the output text
+ example: -length=6
+
+ -IDs={num1};{num2};....
+ required: no (defaults to 1,2,3)
+ What IDs you want to search for. Separated with ','
+ example: -IDs=1;2;3;4;5;6
+
+ -chars=characters
+ required: no (defaults to lowercase alphabet + space + 0-9)
+ The Characters the text can contain.
+ NOTE: Can only be the LAST PARAMETER!!! Otherwise it would be difficult to separate characters/options
+ example: -chars=abcdefgh132465798 ABCDE
+
+ """;
/**
* Characters the text can contain. Change this if you want to
*/
@@ -61,14 +89,14 @@ public class DimensionFinder {
*
-length=6 |
*
*
- * -IDs |
+ * -IDs={num1};{num2};.... |
* no (defaults to 1,2,3) |
* What IDs you want to search for. Separated with ',' |
* -IDs=1;2;3;4;5;6 |
*
*
- * -chars= |
- * mo (defaults to lowercase alphabet + space + 0-9) |
+ * -chars=characters |
+ * no (defaults to lowercase alphabet + space + 0-9) |
* The Characters the text can contain. NOTE: Can only be the LAST PARAMETER!!! Otherwise it would be difficult to separate characters/options |
* -chars=abcdefgh132465798 ABCDE |
*
@@ -131,6 +159,10 @@ public static void main(final String[] args) {
String substring = joined.substring(joined.indexOf("-chars=") + "-chars=".length());
System.out.println("[INFO] Character option is used! Treating " + substring + " as Character Array!");
CHARS = substring.toCharArray();
+ } else if (arg.startsWith("-help")) {
+ System.out.println(HELP_TEXT);
+ } else {
+ System.err.println("Unrecognized Option " + arg + " use -help for help!");
}
}
}
@@ -163,24 +195,34 @@ public static void main(final String[] args) {
System.out.println("Printing results:");
- System.out.println("=".repeat(50));
+ System.out.println("=".
+
+ repeat(50));
result.forEach((integer, strings) -> System.out.printf("Strings for Hash %d: %s%n", integer, Arrays.toString(strings.toArray(new String[0]))));
- System.out.println("=".repeat(50));
+ System.out.println("=".
+ repeat(50));
- try (final BufferedWriter writer = Files.newBufferedWriter(RESULT_PATH)) {
+
+ try (
+ final BufferedWriter writer = Files.newBufferedWriter(RESULT_PATH)) {
for (final Map.Entry> entry : result.entrySet()) {
writer.write(entry.getKey() + ": ");
writer.write(Arrays.toString(entry.getValue().toArray()) + System.lineSeparator());
}
System.out.printf("Saved results as %s%n", RESULT_PATH.toAbsolutePath().toString());
- } catch (final IOException e) {
+ } catch (
+ final IOException e) {
System.err.println("Could not save results as File!");
e.printStackTrace();
}
System.out.println("Program finished. Press Enter to exit...");
- new Scanner(System.in).next();
+ new
+
+ Scanner(System.in).
+
+ next();
System.out.println("Bye!");
System.exit(0);
}