SHl-22 limit history size, remove dead code
This commit is contained in:
@@ -18,51 +18,61 @@ import org.apache.commons.io.FileUtils;
|
||||
* @author vnagaraja
|
||||
*/
|
||||
public class SimpleShellCommandLineOptions {
|
||||
String[] executeThenQuit = null;
|
||||
Map<String, String> extraSystemProperties = new HashMap<String, String>();
|
||||
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<String, String> extraSystemProperties = new HashMap<String, String>();
|
||||
public static SimpleShellCommandLineOptions parseCommandLine(String[] args) throws IOException {
|
||||
SimpleShellCommandLineOptions options = new SimpleShellCommandLineOptions();
|
||||
List<String> commands = new ArrayList<String>();
|
||||
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<String> commands = new ArrayList<String>();
|
||||
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}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user