Install plugin command help (#2193)

* edited opensearch-plugin install help output to include plugin URL

Signed-off-by: Joshua Palis <jpalis@amazon.com>

* fixed unit test for plugin install help output by correctly identifying the beginning og the non-option argument list

Signed-off-by: Joshua Palis <jpalis@amazon.com>

* added comments to install plugins help non option argument ouput unit test

Signed-off-by: Joshua Palis <jpalis@amazon.com>

* fixed format violation

Signed-off-by: Joshua Palis <jpalis@amazon.com>

* added additional details on valid plugin ids and how to use plugin URLs

Signed-off-by: Joshua Palis <jpalis@amazon.com>

* added additional information to plugin install help output

Signed-off-by: Joshua Palis <jpalis@amazon.com>

Co-authored-by: Joshua Palis <jpalis@amazon.com>
This commit is contained in:
joshpalis 2022-02-24 08:58:12 -08:00 committed by GitHub
parent e4357180cc
commit b251d2b565
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 1 deletions

View File

@ -218,11 +218,23 @@ class InstallPluginCommand extends EnvironmentAwareCommand {
Arrays.asList("b", "batch"), Arrays.asList("b", "batch"),
"Enable batch mode explicitly, automatic confirmation of security permission" "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 @Override
protected void printAdditionalHelp(Terminal terminal) { 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:"); terminal.println("The following official plugins may be installed by name:");
for (String plugin : OFFICIAL_PLUGINS) { for (String plugin : OFFICIAL_PLUGINS) {
terminal.println(" " + plugin); terminal.println(" " + plugin);

View File

@ -828,6 +828,31 @@ public class InstallPluginCommandTests extends OpenSearchTestCase {
} }
} }
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 { public void testInstallMisspelledOfficialPlugins() throws Exception {
Tuple<Path, Environment> env = createEnv(fs, temp); Tuple<Path, Environment> env = createEnv(fs, temp);