From f5736ec37aa8950dc097cb5ea9ec997125f6bfd3 Mon Sep 17 00:00:00 2001 From: Ludovic Apvrille <ludovic.apvrille@telecom-paristech.fr> Date: Fri, 17 Apr 2009 10:11:34 +0000 Subject: [PATCH] --- src/RemoteSimulationControl.java | 6 +++-- src/remotesimulation/CommandParser.java | 33 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/RemoteSimulationControl.java b/src/RemoteSimulationControl.java index 9f9b87f20a..a7a7c08247 100755 --- a/src/RemoteSimulationControl.java +++ b/src/RemoteSimulationControl.java @@ -87,6 +87,7 @@ public class RemoteSimulationControl extends Thread { System.out.println("cmd <raw comand>: used to send a raw command to the simulator"); System.out.println("help: print that help"); System.out.println("help <command>: print the help on the given command <command>"); + System.out.println("list: list all possible simulation commands"); System.out.println("quit: quit the remote interface to simulation"); System.out.println("-------------------------------------------------------------\n"); } @@ -219,8 +220,9 @@ public class RemoteSimulationControl extends Thread { System.exit(-1); } else if (cp.isHelpCommand(input)) { printHelp(input); - } else if (cp.isPicoCommand(input)) { - System.out.println("Pico has big teeth"); + } else if (cp.isListCommand(input)) { + System.out.println("Available commands:"); + System.out.println(cp.getCommandList()); } else { if (cp.isAValidCommand(input)) { rc.send(cp.transformCommandFromUserToSimulator(input)); diff --git a/src/remotesimulation/CommandParser.java b/src/remotesimulation/CommandParser.java index 892e9b5266..0b1c9cbb22 100755 --- a/src/remotesimulation/CommandParser.java +++ b/src/remotesimulation/CommandParser.java @@ -72,6 +72,27 @@ public class CommandParser { return isCommand(cmd, "help"); } + // Returns the command name for which help is required + public String getHelpWithCommand(String cmd) { + if (!isCommand(cmd, "help")) { + return null; + } + + String tmp = cmd.trim(); + + if (!(tmp.startsWith("help "))) { + return null; + } + + tmp = tmp.substring(5, tmp.length()).trim(); + + if (tmp.length() == 0) { + return null; + } + + return tmp; + } + public boolean isQuitCommand(String cmd) { return isCommand(cmd, "quit"); } @@ -80,6 +101,10 @@ public class CommandParser { return isCommand(cmd, "pico"); } + public boolean isListCommand(String cmd) { + return isCommand(cmd, "list"); + } + public boolean isAValidCommand(String cmd) { return true; } @@ -88,6 +113,14 @@ public class CommandParser { return cmd; } + public String getCommandList() { + StringBuffer sb = new StringBuffer(""); + for(SimulationCommand sc: commandList) { + sb.append(sc.userCommand); + } + return sb.toString(); + } + private void fillCommandList() { SimulationCommand sc; -- GitLab