mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-06 04:58:50 +00:00
PluginManager fails with unknown command when passing url or verbose parameters
Closes #3245.
This commit is contained in:
parent
cb34cccc1e
commit
5a20ba5ff2
@ -46,6 +46,12 @@ import static org.elasticsearch.common.settings.ImmutableSettings.Builder.EMPTY_
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PluginManager {
|
public class PluginManager {
|
||||||
|
public static final class ACTION {
|
||||||
|
public static final int NONE = 0;
|
||||||
|
public static final int INSTALL = 1;
|
||||||
|
public static final int REMOVE = 2;
|
||||||
|
public static final int LIST = 3;
|
||||||
|
}
|
||||||
|
|
||||||
private final Environment environment;
|
private final Environment environment;
|
||||||
|
|
||||||
@ -309,69 +315,80 @@ public class PluginManager {
|
|||||||
|
|
||||||
String url = null;
|
String url = null;
|
||||||
boolean verbose = false;
|
boolean verbose = false;
|
||||||
for (int i = 0; i < args.length; i++) {
|
String pluginName = null;
|
||||||
String command = args[i];
|
int action = ACTION.NONE;
|
||||||
if ("-u".equals(command) || "--url".equals(command)
|
|
||||||
// Deprecated commands
|
|
||||||
|| "url".equals(command) || "-url".equals(command)) {
|
|
||||||
try {
|
|
||||||
url = args[i + 1];
|
|
||||||
} catch (Exception e) {
|
|
||||||
displayHelp("Error while installing plugin, reason: " + e.getClass().getSimpleName() +
|
|
||||||
": " + e.getMessage());
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
} else if ("-v".equals(command) || "--v".equals(command)
|
|
||||||
|| "verbose".equals(command) || "-verbose".equals(command)) {
|
|
||||||
verbose = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PluginManager pluginManager = new PluginManager(initialSettings.v2(), url);
|
|
||||||
|
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
displayHelp(null);
|
displayHelp(null);
|
||||||
}
|
}
|
||||||
for (int c = 0; c < args.length; c++) {
|
|
||||||
String command = args[c];
|
try {
|
||||||
if (command.equals("-i") || command.equals("--install")
|
for (int c = 0; c < args.length; c++) {
|
||||||
// Deprecated commands
|
String command = args[c];
|
||||||
|| command.equals("install") || command.equals("-install")) {
|
if ("-u".equals(command) || "--url".equals(command)
|
||||||
String pluginName = null;
|
// Deprecated commands
|
||||||
try {
|
|| "url".equals(command) || "-url".equals(command)) {
|
||||||
|
url = args[++c];
|
||||||
|
} else if ("-v".equals(command) || "--v".equals(command)
|
||||||
|
|| "verbose".equals(command) || "-verbose".equals(command)) {
|
||||||
|
verbose = true;
|
||||||
|
} else if (command.equals("-i") || command.equals("--install")
|
||||||
|
// Deprecated commands
|
||||||
|
|| command.equals("install") || command.equals("-install")) {
|
||||||
pluginName = args[++c];
|
pluginName = args[++c];
|
||||||
System.out.println("-> Installing " + pluginName + "...");
|
action = ACTION.INSTALL;
|
||||||
pluginManager.downloadAndExtract(pluginName, verbose);
|
|
||||||
} catch (IOException e) {
|
} else if (command.equals("-r") || command.equals("--remove")
|
||||||
System.out.println("Failed to install " + pluginName + ", reason: " + e.getMessage());
|
// Deprecated commands
|
||||||
} catch (Exception e) {
|
|| command.equals("remove") || command.equals("-remove")) {
|
||||||
displayHelp("Error while installing plugin, reason: " + e.getClass().getSimpleName() +
|
pluginName = args[++c];
|
||||||
": " + e.getMessage());
|
action = ACTION.REMOVE;
|
||||||
|
} else if (command.equals("-l") || command.equals("--list")) {
|
||||||
|
action = ACTION.LIST;
|
||||||
|
} else if (command.equals("-h") || command.equals("--help")) {
|
||||||
|
displayHelp(null);
|
||||||
|
} else {
|
||||||
|
displayHelp("Command [" + args[c] + "] unknown.");
|
||||||
|
// Unknown command. We break...
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
} else if (command.equals("-r") || command.equals("--remove")
|
}
|
||||||
// Deprecated commands
|
} catch (Exception e) {
|
||||||
|| command.equals("remove") || command.equals("-remove")) {
|
displayHelp("Error while parsing options: " + e.getClass().getSimpleName() +
|
||||||
String pluginName = null;
|
": " + e.getMessage());
|
||||||
try {
|
System.exit(1);
|
||||||
pluginName = args[++c];
|
}
|
||||||
System.out.println("-> Removing " + pluginName + " ");
|
|
||||||
pluginManager.removePlugin(pluginName);
|
if (action > ACTION.NONE) {
|
||||||
} catch (IOException e) {
|
PluginManager pluginManager = new PluginManager(initialSettings.v2(), url);
|
||||||
System.out.println("Failed to remove " + pluginName + ", reason: " + e.getMessage());
|
|
||||||
} catch (Exception e) {
|
switch (action) {
|
||||||
displayHelp("Error while removing plugin, reason: " + e.getClass().getSimpleName() +
|
case ACTION.INSTALL:
|
||||||
": " + e.getMessage());
|
try {
|
||||||
}
|
System.out.println("-> Installing " + pluginName + "...");
|
||||||
} else if (command.equals("-l") || command.equals("--list")) {
|
pluginManager.downloadAndExtract(pluginName, verbose);
|
||||||
pluginManager.listInstalledPlugins();
|
} catch (IOException e) {
|
||||||
} else if (command.equals("-h") || command.equals("--help")) {
|
System.out.println("Failed to install " + pluginName + ", reason: " + e.getMessage());
|
||||||
displayHelp(null);
|
} catch (Exception e) {
|
||||||
} else {
|
displayHelp("Error while installing plugin, reason: " + e.getClass().getSimpleName() +
|
||||||
displayHelp("Command [" + args[c] + "] unknown.");
|
": " + e.getMessage());
|
||||||
// Unknown command. We break...
|
System.exit(1);
|
||||||
System.exit(1);
|
}
|
||||||
|
break;
|
||||||
|
case ACTION.REMOVE:
|
||||||
|
try {
|
||||||
|
System.out.println("-> Removing " + pluginName + " ");
|
||||||
|
pluginManager.removePlugin(pluginName);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Failed to remove " + pluginName + ", reason: " + e.getMessage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
displayHelp("Error while removing plugin, reason: " + e.getClass().getSimpleName() +
|
||||||
|
": " + e.getMessage());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ACTION.LIST:
|
||||||
|
pluginManager.listInstalledPlugins();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user