diff --git a/samples/helloworld/pom.xml b/samples/helloworld/pom.xml
index 7707ba9d..1d7133a8 100644
--- a/samples/helloworld/pom.xml
+++ b/samples/helloworld/pom.xml
@@ -88,7 +88,7 @@
spring-maven-snapshot
true
- always
+
Springframework Maven SNAPSHOT Repository
http://maven.springframework.org/snapshot
diff --git a/samples/helloworld/src/main/java/org/springframework/shell/samples/helloworld/commands/HelloWorldCommands.java b/samples/helloworld/src/main/java/org/springframework/shell/samples/helloworld/commands/HelloWorldCommands.java
index 21e0e5a6..bed9a749 100644
--- a/samples/helloworld/src/main/java/org/springframework/shell/samples/helloworld/commands/HelloWorldCommands.java
+++ b/samples/helloworld/src/main/java/org/springframework/shell/samples/helloworld/commands/HelloWorldCommands.java
@@ -17,7 +17,9 @@ public class HelloWorldCommands implements CommandMarker {
@CliCommand(value = "hw echo", help = "Print a hello world message")
public void config(
- @CliOption(key = { "message" }, mandatory = true, help = "The hello world message") final String message) {
- System.out.println("Hello world " + message);
+ @CliOption(key = { "message" }, mandatory = true, help = "The hello world message") final String message,
+ @CliOption(key = { "name" }, mandatory = true, help = "The hello world name ") final String name,
+ @CliOption(key = { "time" }, mandatory = false, help = "The hello world time ") final String time) {
+ System.out.println("Hello world " + message + "," + name + ". time:" + time);
}
}
diff --git a/src/main/java/org/springframework/roo/shell/SimpleParser.java b/src/main/java/org/springframework/roo/shell/SimpleParser.java
index 88210ee2..eacd50a6 100644
--- a/src/main/java/org/springframework/roo/shell/SimpleParser.java
+++ b/src/main/java/org/springframework/roo/shell/SimpleParser.java
@@ -270,7 +270,7 @@ public class SimpleParser implements Parser {
}
protected void commandNotFound(final Logger logger, final String buffer) {
- logger.warning("Command '" + buffer + "' not found (for assistance press " + AbstractShell.completionKeys + " or type \"hint\" then hit ENTER)");
+ logger.warning("Command '" + buffer + "' not found (for assistance press " + AbstractShell.completionKeys + ")");
}
private Collection locateTargets(final String buffer, final boolean strictMatching, final boolean checkAvailabilityIndicators) {
diff --git a/src/main/java/org/springframework/shell/Bootstrap.java b/src/main/java/org/springframework/shell/Bootstrap.java
index 5572efaf..32af2bdd 100644
--- a/src/main/java/org/springframework/shell/Bootstrap.java
+++ b/src/main/java/org/springframework/shell/Bootstrap.java
@@ -45,7 +45,7 @@ public class Bootstrap {
}
ExitShellRequest exitShellRequest;
try {
- bootstrap = new Bootstrap(options.applicationContextLocation);
+ bootstrap = new Bootstrap(null);
exitShellRequest = bootstrap.run(options.executeThenQuit);
} catch (RuntimeException t) {
throw t;
@@ -57,12 +57,11 @@ public class Bootstrap {
}
public Bootstrap(String applicationContextLocation) throws IOException {
- //setupLogging();
- Assert.hasText(applicationContextLocation, "Application context location required");
- createApplicationContext(applicationContextLocation);
+ createApplicationContext();
shell = ctx.getBean("shell", JLineShellComponent.class);
shell.setApplicationContext(ctx);
+ shell.setHistorySize(options.historySize);
if (options.executeThenQuit != null) {
shell.setPrintBanner(false);
}
@@ -96,7 +95,7 @@ public class Bootstrap {
}
- private void createApplicationContext(String applicationContextLocation) {
+ private void createApplicationContext() {
AnnotationConfigApplicationContext annctx = new AnnotationConfigApplicationContext();
createAndRegisterBeanDefinition(annctx, org.springframework.roo.shell.converters.StringConverter.class);
createAndRegisterBeanDefinition(annctx,
diff --git a/src/main/java/org/springframework/shell/JLineShell.java b/src/main/java/org/springframework/shell/JLineShell.java
index 795fb859..59a1d0f5 100644
--- a/src/main/java/org/springframework/shell/JLineShell.java
+++ b/src/main/java/org/springframework/shell/JLineShell.java
@@ -95,6 +95,7 @@ public abstract class JLineShell extends AbstractShell
private String version;
private String welcomeMessage;
+ private int historySize;
public void run() {
try {
@@ -137,9 +138,14 @@ public abstract class JLineShell extends AbstractShell
String logFileContents = FileCopyUtils.copyToString(new File(this.historyFileName));
String[] logEntries = logFileContents.split(StringUtils.LINE_SEPARATOR);
// LIFO
+ int size = 0;
for (String logEntry : logEntries) {
if (!logEntry.startsWith("//")) {
reader.getHistory().addToHistory(logEntry);
+ size++;
+ if(size > historySize){
+ break;
+ }
}
}
} catch (IOException ignored) {
@@ -561,7 +567,7 @@ public abstract class JLineShell extends AbstractShell
* get prompt text from provider. The provider has highest order
* org.springframework.core.Ordered.getOder will win.
*
- * @return
+ * @return prompt text
*/
private String getPromptText(){
return getHighestPriorityProvider(PromptProvider.class).getPromptText();
@@ -591,11 +597,20 @@ public abstract class JLineShell extends AbstractShell
return highestPriorityProvider;
}
+ /**
+ * get the version information
+ *
+ */
@Override
public String version(String text){
return this.version;
}
+ /**
+ * get the welcome message at start.
+ *
+ * @return welcome message
+ */
public String getWelcomeMessage(){
return this.welcomeMessage;
}
@@ -607,5 +622,19 @@ public abstract class JLineShell extends AbstractShell
public void setPrintBanner(boolean printBanner) {
this.printBanner = printBanner;
}
+
+ /**
+ * @return the historySize
+ */
+ public int getHistorySize() {
+ return historySize;
+ }
+
+ /**
+ * @param historySize the historySize to set
+ */
+ public void setHistorySize(int historySize) {
+ this.historySize = historySize;
+ }
}
diff --git a/src/main/java/org/springframework/shell/SimpleShellCommandLineOptions.java b/src/main/java/org/springframework/shell/SimpleShellCommandLineOptions.java
index 17e43ef0..f08af645 100644
--- a/src/main/java/org/springframework/shell/SimpleShellCommandLineOptions.java
+++ b/src/main/java/org/springframework/shell/SimpleShellCommandLineOptions.java
@@ -18,51 +18,61 @@ import org.apache.commons.io.FileUtils;
* @author vnagaraja
*/
public class SimpleShellCommandLineOptions {
+ String[] executeThenQuit = null;
+ Map extraSystemProperties = new HashMap();
+ int historySize = 3000;
- public static final String DEFAULT_APP_CTX = "classpath*:/META-INF/spring/app-context.xml";
- String applicationContextLocation = DEFAULT_APP_CTX;
- String[] executeThenQuit = null;
- Map extraSystemProperties = new HashMap();
+ public static SimpleShellCommandLineOptions parseCommandLine(String[] args) throws IOException {
+ SimpleShellCommandLineOptions options = new SimpleShellCommandLineOptions();
+ List commands = new ArrayList();
+ int i = 0;
+ while (i < args.length) {
+ String arg = args[i++];
+ if (arg.equals("--environment")) {
+ String environment = args[i++];
+ options.extraSystemProperties.put("napa.application.profile", environment);
+ }
+ else if (arg.equals("--cmdfile")) {
+ File f = new File(args[i++]);
+ commands.addAll(FileUtils.readLines(f));
+ }
+ else if (arg.equals("--histsize")) {
+ options.historySize = Integer.parseInt(args[i++]);
+ }
+ else if (arg.equals("--help")) {
+ printUsage();
+ System.exit(0);
+ }
+ else {
+ i--;
+ break;
+ }
+ }
- public static SimpleShellCommandLineOptions parseCommandLine(String[] args) throws IOException {
- SimpleShellCommandLineOptions options = new SimpleShellCommandLineOptions();
- List commands = new ArrayList();
- int i = 0;
- while (i < args.length) {
- String arg = args[i++];
- if (arg.equals("-environment")) {
- String environment = args[i++];
- options.extraSystemProperties.put("napa.application.profile", environment);
- } else if (arg.equals("-ctx")) {
- options.applicationContextLocation = args[i++];
- } else if (arg.equals("-cmdfile")) {
- File f = new File(args[i++]);
- commands.addAll(FileUtils.readLines(f));
- } else {
- i--;
- break;
- }
- }
+ StringBuilder sb = new StringBuilder();
+ for (; i < args.length; i++) {
+ if (sb.length() > 0) {
+ sb.append(" ");
+ }
+ sb.append(args[i]);
+ }
- StringBuilder sb = new StringBuilder();
- for (; i < args.length; i++) {
- if (sb.length() > 0) {
- sb.append(" ");
- }
- sb.append(args[i]);
- }
+ if (sb.length() > 0) {
+ String[] cmdLineCommands = sb.toString().split(";");
+ for (String s : cmdLineCommands) {
+ //add any command line commands after the commands loaded from the file
+ commands.add(s.trim());
+ }
+ }
- if(sb.length()>0) {
- String[] cmdLineCommands = sb.toString().split(";");
- for(String s : cmdLineCommands) {
- //add any command line commands after the commands loaded from the file
- commands.add(s.trim());
- }
- }
+ if (commands.size() > 0)
+ options.executeThenQuit = commands.toArray(new String[commands.size()]);
- if(commands.size()>0)
- options.executeThenQuit = commands.toArray(new String[commands.size()]);
-
- return options;
- }
+ return options;
+ }
+
+ private static void printUsage(){
+ System.out.println("Usage:");
+ System.out.println("java -jar {jarname} --help --histsize {size} --cmdfile {file}");
+ }
}
diff --git a/src/main/resources/META-INF/spring/app-context.xml b/src/main/resources/META-INF/spring/app-context.xml
deleted file mode 100644
index 1dbc536d..00000000
--- a/src/main/resources/META-INF/spring/app-context.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
- Example configuration to get you started.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-