summaryrefslogtreecommitdiff
path: root/clformat
diff options
context:
space:
mode:
Diffstat (limited to 'clformat')
-rw-r--r--clformat/example-format-strings.sprop6
-rw-r--r--clformat/src/example/java/bjc/utils/ioutils/format/examples/CLFormatCLI.java40
2 files changed, 46 insertions, 0 deletions
diff --git a/clformat/example-format-strings.sprop b/clformat/example-format-strings.sprop
new file mode 100644
index 0000000..6de136a
--- /dev/null
+++ b/clformat/example-format-strings.sprop
@@ -0,0 +1,6 @@
+# Dump hexadecimal output in some manner
+dumpHexOutput ~:{~8,'0X: ~2{~8@{~# ~:;~2,'0X ~]~} ~}~v@{ ~}~2{~8@{~A~} ~}~%~}
+# Print a list in proper English style (no Oxford comma)
+englishList ~#[ none~; ~A~; ~A and ~A:;~@{~#*[ ~A,~; and ~A~; ~A~]~}~]
+# An alternate variant which abbreviates long lists
+abbrevList ~#[NONE~;~a~;~a and ~a~:;~a, ~a~]~#[~; and ~a~:;, ~a, etc~]
diff --git a/clformat/src/example/java/bjc/utils/ioutils/format/examples/CLFormatCLI.java b/clformat/src/example/java/bjc/utils/ioutils/format/examples/CLFormatCLI.java
new file mode 100644
index 0000000..71e6b92
--- /dev/null
+++ b/clformat/src/example/java/bjc/utils/ioutils/format/examples/CLFormatCLI.java
@@ -0,0 +1,40 @@
+package bjc.utils.ioutils.format.examples;
+
+import java.io.*;
+import java.util.*;
+
+public class CLFormatCLI {
+ public static void main(String[] args) {
+ Scanner scn = new Scanner(System.in);
+ PrintStream output = System.out;
+
+ runCLI(scn, output);
+ }
+
+ private static void runCLI(Scanner input, PrintStream output) {
+ output.println("CLFormat CLI v0.1");
+ output.println("Enter a command (m for help)");
+
+ String inp = input.nextLine().trim();
+
+ boolean verboseErrors = false;
+
+ while (!inp.equals("q")) {
+ String[] args = inp.split("\\S+");
+
+ String command = args[0];
+ switch(command) {
+ default:
+ if (verboseErrors) {
+ output.printf("! Error: %s is not a recognizable command\n", inp);
+ } else {
+ output.println("! UC");
+ }
+ }
+
+ output.println("Enter a command (m for help)");
+
+ String inp = input.nextLine().trim();
+ }
+ }
+}