* @param args Command line arguments
* @throws Exception
*/
public static void main (String[] args) throws Exception {
System.setProperty("groovysh.prompt", Constants.SQOOP_PROMPT);
Groovysh shell = new Groovysh();
// Install our error hook (exception handling)
shell.setErrorHook(new MethodClosure(ThrowableDisplayer.class, "errorHook"));
CommandRegistry registry = shell.getRegistry();
@SuppressWarnings("unchecked")
Iterator<Command> iterator = registry.iterator();
while (iterator.hasNext()) {
Command command = iterator.next();
if (!commandsToKeep.contains(command.getName())) {
iterator.remove();
// remove from "names" set to avoid duplicate error.
registry.remove(command);
}
}
shell.register(new HelpCommand(shell));
shell.register(new SetCommand(shell));
shell.register(new ShowCommand(shell));
shell.register(new CreateCommand(shell));
shell.register(new DeleteCommand(shell));
shell.register(new UpdateCommand(shell));
shell.register(new CloneCommand(shell));
shell.register(new StartCommand(shell));
shell.register(new StopCommand(shell));
shell.register(new StatusCommand(shell));
shell.register(new EnableCommand(shell));
shell.register(new DisableCommand(shell));
// Configure shared shell io object
setIo(shell.getIo());
// We're running in batch mode by default
setInteractive(false);
// Let's see if user do have resource file with initial commands that he
// would like to apply.
String homeDir = System.getProperty(Constants.PROP_HOMEDIR);
File rcFile = new File(homeDir, RC_FILE);
if(rcFile.exists()) {
printlnResource(Constants.RES_SQOOP_PROMPT_SHELL_LOADRC, RC_FILE);
interpretFileContent(rcFile, shell);
printlnResource(Constants.RES_SQOOP_PROMPT_SHELL_LOADEDRC);
}
if (args.length == 0) {
// Interactive mode:
getIo().setVerbosity(Verbosity.QUIET);
printlnResource(Constants.RES_SQOOP_SHELL_BANNER);
println();
// Switch to interactive mode
setInteractive(true);
shell.run(args);
} else {
// Batch mode (with a script file):
File script = new File(args[0]);
if (!script.isAbsolute()) {