SHL-91 SHL-80 Provide ability to disable built-in commands
This commit is contained in:
@@ -286,6 +286,15 @@ public class HelloWorldCommands implements CommandMarker {
|
||||
lines to store in the command history file. Default value is
|
||||
3000.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><literal>--disableInternalCommands</literal> - Flag that disables all commands that would
|
||||
be pre-registered with the shell. There is no argument to this option. You can selectively add
|
||||
back any internal commands by referencing them in your shell plugin file. Look at the
|
||||
Spring Shell javadocs for specific commands located in the
|
||||
<literal>org.springframework.shell.commands</literal> package as well as the section in this documentation
|
||||
of Built in commands.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
springShellVersion = 1.1.0.M1
|
||||
springShellVersion = 1.1.0.BUILD-SNAPSHOT
|
||||
junitVersion = 4.10
|
||||
log4jVersion = 1.2.17
|
||||
version = 1.0.0.RELEASE
|
||||
|
||||
@@ -86,7 +86,11 @@ public class Bootstrap {
|
||||
configureApplicationContext(ctx);
|
||||
//built-in commands and converters
|
||||
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(ctx);
|
||||
scanner.scan("org.springframework.shell.commands", "org.springframework.shell.converters", "org.springframework.shell.plugin.support");
|
||||
if (commandLine.getDisableInternalCommands()) {
|
||||
scanner.scan("org.springframework.shell.converters", "org.springframework.shell.plugin.support");
|
||||
} else {
|
||||
scanner.scan("org.springframework.shell.commands", "org.springframework.shell.converters", "org.springframework.shell.plugin.support");
|
||||
}
|
||||
//user contributed commands
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader((BeanDefinitionRegistry) ctx);
|
||||
reader.loadBeanDefinitions(contextPath);
|
||||
|
||||
@@ -26,6 +26,7 @@ public class CommandLine {
|
||||
private String[] args;
|
||||
private int historySize;
|
||||
private String[] shellCommandsToExecute;
|
||||
private boolean disableInteralCommands;
|
||||
|
||||
/**
|
||||
* Construct a new CommandLine
|
||||
@@ -33,10 +34,11 @@ public class CommandLine {
|
||||
* @param historySize the size of this history buffer
|
||||
* @param shellCommandsToExecute semi-colon delimited list of commands for the shell to execute
|
||||
*/
|
||||
public CommandLine(String[] args, int historySize, String[] shellCommandsToExecute) {
|
||||
public CommandLine(String[] args, int historySize, String[] shellCommandsToExecute, boolean disableInteralCommands) {
|
||||
this.args = args;
|
||||
this.historySize = historySize;
|
||||
this.shellCommandsToExecute = shellCommandsToExecute;
|
||||
this.disableInteralCommands = disableInteralCommands;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,5 +62,13 @@ public class CommandLine {
|
||||
public String[] getShellCommandsToExecute() {
|
||||
return shellCommandsToExecute;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the disableInteralCommands value
|
||||
*/
|
||||
public boolean getDisableInternalCommands() {
|
||||
return disableInteralCommands;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public class SimpleShellCommandLineOptions {
|
||||
String[] executeThenQuit = null;
|
||||
Map<String, String> extraSystemProperties = new HashMap<String, String>();
|
||||
int historySize = DEFAULT_HISTORY_SIZE;
|
||||
boolean disableCommands;
|
||||
|
||||
public static CommandLine parseCommandLine(String[] args)
|
||||
throws IOException {
|
||||
@@ -79,6 +80,8 @@ public class SimpleShellCommandLineOptions {
|
||||
} catch (ArrayIndexOutOfBoundsException ae) {
|
||||
LOGGER.warning("No value specified for --histsize option");
|
||||
}
|
||||
} else if (arg.equals("--disableInternalCommands")) {
|
||||
options.disableCommands = true;
|
||||
} else if (arg.equals("--help")) {
|
||||
printUsage();
|
||||
System.exit(0);
|
||||
@@ -112,7 +115,7 @@ public class SimpleShellCommandLineOptions {
|
||||
System.setProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
return new CommandLine(args, options.historySize, options.executeThenQuit);
|
||||
return new CommandLine(args, options.historySize, options.executeThenQuit, options.disableCommands);
|
||||
}
|
||||
|
||||
private static void printUsage() {
|
||||
|
||||
Reference in New Issue
Block a user