summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/cli/CLICommander.java
diff options
context:
space:
mode:
authorbculkin2442 <bjculkin@mix.wvu.edu>2016-04-06 13:50:00 -0400
committerbculkin2442 <bjculkin@mix.wvu.edu>2016-04-06 13:50:00 -0400
commit79d3a4a47cbc1fcf17c77c6fc12ff826a3077bac (patch)
treea69e533c558326d583b3aee891fc815208c7b650 /BJC-Utils2/src/main/java/bjc/utils/cli/CLICommander.java
parent4355418164c44170cfb329fcbb7e6f1358c0e314 (diff)
Minor bugfixes/changes, as well as beginnings of CLI systems
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/cli/CLICommander.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/cli/CLICommander.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/cli/CLICommander.java b/BJC-Utils2/src/main/java/bjc/utils/cli/CLICommander.java
new file mode 100644
index 0000000..f48f08e
--- /dev/null
+++ b/BJC-Utils2/src/main/java/bjc/utils/cli/CLICommander.java
@@ -0,0 +1,60 @@
+package bjc.utils.cli;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * Runs a CLI interface from the provided set of streams
+ *
+ * @author ben
+ *
+ */
+public class CLICommander {
+ private InputStream input;
+ private OutputStream output;
+ private OutputStream error;
+ private ICommandMode initialMode;
+
+ /**
+ * Create a new CLI interface powered by streams
+ *
+ * @param input
+ * The stream to get user input from
+ * @param output
+ * The stream to send user output to
+ * @param error
+ * The stream to send error messages to
+ */
+ public CLICommander(InputStream input, OutputStream output,
+ OutputStream error) {
+ if (input == null) {
+ throw new NullPointerException(
+ "Input stream must not be null");
+ } else if (output == null) {
+ throw new NullPointerException(
+ "Output stream must not be null");
+ } else if (error == null) {
+ throw new NullPointerException(
+ "Error stream must not be null");
+ }
+
+ this.input = input;
+ this.output = output;
+ this.error = error;
+ }
+
+ /**
+ * Set the initial command mode to use
+ *
+ * @param initialMode
+ * The initial command mode to use
+ */
+ public void setInitialCommandMode(ICommandMode initialMode) {
+ if (initialMode == null) {
+ throw new NullPointerException(
+ "Initial mode must be non-zero");
+ }
+
+ this.initialMode = initialMode;
+ }
+}