Commit e30a44aa authored by Jonathan Shahen's avatar Jonathan Shahen

Adds the '!prev' command to the CUI

parent eabb06b9
package mohawk; package mohawk;
import java.io.*; import java.io.*;
import java.util.ArrayList; import java.util.*;
import java.util.Scanner;
import org.apache.commons.cli.Options; import org.apache.commons.cli.Options;
public class MohawkCUI { public class MohawkCUI {
public static String previousCommandFilename = "MohawkCUIPreviousCommand.txt"; public static String previousCommandFilename = "MohawkCUIPreviousCommand.txt";
public static String previousCmd;
public static void main(String[] args) { public static void main(String[] args) {
MohawkInstance inst = new MohawkInstance(); MohawkInstance inst = new MohawkInstance();
...@@ -48,17 +48,25 @@ public class MohawkCUI { ...@@ -48,17 +48,25 @@ public class MohawkCUI {
if (cmd.equals("!exit")) { if (cmd.equals("!exit")) {
break; break;
} }
if (cmd.equals("!prev")) {
argv.clear();
argv.addAll(Arrays.asList(previousCmd.split(" ")));
break;
}
argv.add(cmd); argv.add(cmd);
} }
user_input.close(); user_input.close();
System.out.println("Commands: " + argv); System.out.println("Commands: " + argv);
FileWriter fw;
try { try {
fw = new FileWriter(previousCommandFilename, false); if (!cmd.equals("!prev")) {
fw.write(fullCommand.toString()); FileWriter fw;
fw.close(); fw = new FileWriter(previousCommandFilename, false);
fw.write(fullCommand.toString());
fw.close();
}
} catch (IOException e) { } catch (IOException e) {
System.out.println("[ERROR] Unable to write out previous command to: " + previousCommandFilename); System.out.println("[ERROR] Unable to write out previous command to: " + previousCommandFilename);
} }
...@@ -86,12 +94,13 @@ public class MohawkCUI { ...@@ -86,12 +94,13 @@ public class MohawkCUI {
System.out.println("-mode bmc -run all -bulk -input data/testcases/mixed !exit"); System.out.println("-mode bmc -run all -bulk -input data/testcases/mixed !exit");
System.out.println(""); System.out.println("");
System.out.println("-mode bmc -run all -input data/ahn/test.st.mohawk.T.mohawk !exit"); System.out.println("-mode bmc -run all -input data/ahn/test.st.mohawk.T.mohawk !exit");
System.out.println("-mode bmc -run all -input data/bug/isolation/ -skiprefine -bulk !exit");
System.out.println(""); System.out.println("");
try { try {
BufferedReader bfr = new BufferedReader(new FileReader(previousCommandFilename)); BufferedReader bfr = new BufferedReader(new FileReader(previousCommandFilename));
String previousCmd = bfr.readLine(); previousCmd = bfr.readLine();
bfr.close(); bfr.close();
System.out.println("Previous Command: " + previousCmd); System.out.println("Previous Command ('!prev' to use the previous command): " + previousCmd);
} catch (IOException e) { } catch (IOException e) {
System.out.println("[ERROR] Unable to load previous command!"); System.out.println("[ERROR] Unable to load previous command!");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment