Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 1.x] Install plugin command help (#2193) #2264

Merged
merged 1 commit into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,23 @@ class InstallPluginCommand extends EnvironmentAwareCommand {
Arrays.asList("b", "batch"),
"Enable batch mode explicitly, automatic confirmation of security permission"
);
this.arguments = parser.nonOptions("plugin id");
this.arguments = parser.nonOptions("plugin <name|Zip File|URL>");
}

@Override
protected void printAdditionalHelp(Terminal terminal) {
terminal.println("Plugins are packaged as zip files. Each packaged plugin must contain a plugin properties file.");
terminal.println("");

// List possible plugin id inputs
terminal.println("The install command takes a plugin id, which may be any of the following:");
terminal.println(" An official opensearch plugin name");
terminal.println(" Maven coordinates to a plugin zip");
terminal.println(" A URL to a plugin zip");
terminal.println(" A local zip file");
terminal.println("");

// List official opensearch plugin names
terminal.println("The following official plugins may be installed by name:");
for (String plugin : OFFICIAL_PLUGINS) {
terminal.println(" " + plugin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,31 @@ protected boolean addShutdownHook() {
}
}

public void testPluginsHelpNonOptionArgumentsOutput() throws Exception {
MockTerminal terminal = new MockTerminal();
new InstallPluginCommand() {
@Override
protected boolean addShutdownHook() {
return false;
}
}.main(new String[] { "--help" }, terminal);
try (BufferedReader reader = new BufferedReader(new StringReader(terminal.getOutput()))) {

// grab first line of --help output
String line = reader.readLine();

// find the beginning of Non-option arguments list
while (line.contains("Non-option arguments:") == false) {
line = reader.readLine();
}

// check that non option agrument list contains correct string
line = reader.readLine();
assertThat(line, containsString("<name|Zip File|URL>"));

}
}

public void testInstallMisspelledOfficialPlugins() throws Exception {
Tuple<Path, Environment> env = createEnv(fs, temp);

Expand Down