summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/cli/objects/BlockReaderCLI.java
diff options
context:
space:
mode:
authorBenjamin J. Culkin <bjculkin@mix.wvu.edu>2017-09-10 21:07:22 -0300
committerBenjamin J. Culkin <bjculkin@mix.wvu.edu>2017-09-10 21:07:22 -0300
commitea88542aec97f570a01303a7e73336701e266259 (patch)
tree1f42ab95f87c5b3ab0e9fb1753de062242fbb53c /BJC-Utils2/src/main/java/bjc/utils/cli/objects/BlockReaderCLI.java
parentd766896972c9e9be4a9e0021ec5f4f0665901865 (diff)
More BlockReader work
This includes some minor fixes to the BlockReaderCLI, and two new BlockReader types * MappedBlockReader - Apply a function to each block, transforming it. * FlatMappedBlockReader - Apply a function to each block, expanding it into one or more blocks.
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/cli/objects/BlockReaderCLI.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/cli/objects/BlockReaderCLI.java19
1 files changed, 12 insertions, 7 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/cli/objects/BlockReaderCLI.java b/BJC-Utils2/src/main/java/bjc/utils/cli/objects/BlockReaderCLI.java
index 115f782..5a87a9a 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/cli/objects/BlockReaderCLI.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/cli/objects/BlockReaderCLI.java
@@ -46,7 +46,7 @@ public class BlockReaderCLI {
BlockReaderCLI reader = new BlockReaderCLI(sources);
- reader.run(new Scanner(System.in), "console");
+ reader.run(new Scanner(System.in), "console", true);
}
/**
@@ -56,11 +56,15 @@ public class BlockReaderCLI {
* The place to read input from.
* @param ioSource
* The name of the place to read input from.
+ * @param interactive
+ * Whether or not the source is interactive
*/
- public void run(Scanner input, String ioSource) {
+ public void run(Scanner input, String ioSource, boolean interactive) {
int lno = 0;
while(input.hasNextLine()) {
- System.out.printf("reader-conf(%d)>", lno);
+ if(interactive)
+ System.out.printf("reader-conf(%d)>", lno);
+
String ln = input.nextLine();
lno += 1;
@@ -68,7 +72,7 @@ public class BlockReaderCLI {
Command com = Command.fromString(ln, lno, ioSource);
if(com == null) continue;
- handleCommand(com);
+ handleCommand(com, true);
}
input.close();
@@ -77,7 +81,7 @@ public class BlockReaderCLI {
/*
* Handle a command.
*/
- public void handleCommand(Command com) {
+ public void handleCommand(Command com, boolean interactive) {
switch(com.nameCommand) {
case "def-filtered":
defFiltered(com);
@@ -96,8 +100,9 @@ public class BlockReaderCLI {
break;
case "exit":
case "quit":
- System.out.printf("Exiting reader-conf, %d readers configured in %d commands\n",
- readers.size(), com.lineNo);
+ if(interactive)
+ System.out.printf("Exiting reader-conf, %d readers configured in %d commands\n",
+ readers.size(), com.lineNo);
break;
default:
System.err.print(com.error("Unknown command '%s'\n", com.nameCommand));