Skip to content

Commit

Permalink
Merge pull request quarkusio#20525 from ebullient/quarkus-20522
Browse files Browse the repository at this point in the history
CLI: fix help commands + test
  • Loading branch information
aloubyansky authored Oct 4, 2021
2 parents 597f550 + 4d706e6 commit 917e3d2
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 11 deletions.
4 changes: 4 additions & 0 deletions devtools/cli/src/main/java/io/quarkus/cli/Create.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;
import java.util.concurrent.Callable;

import io.quarkus.cli.common.HelpOption;
import io.quarkus.cli.common.OutputOptionMixin;
import picocli.CommandLine;
import picocli.CommandLine.ParseResult;
Expand All @@ -17,6 +18,9 @@ public class Create implements Callable<Integer> {
@CommandLine.Mixin
protected OutputOptionMixin output;

@CommandLine.Mixin
protected HelpOption helpOption;

@CommandLine.Spec
protected CommandLine.Model.CommandSpec spec;

Expand Down
4 changes: 4 additions & 0 deletions devtools/cli/src/main/java/io/quarkus/cli/Registry.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;
import java.util.concurrent.Callable;

import io.quarkus.cli.common.HelpOption;
import io.quarkus.cli.common.OutputOptionMixin;
import picocli.CommandLine;
import picocli.CommandLine.ParseResult;
Expand All @@ -17,6 +18,9 @@ public class Registry implements Callable<Integer> {
@CommandLine.Mixin
protected OutputOptionMixin output;

@CommandLine.Mixin
protected HelpOption helpOption;

@CommandLine.Spec
protected CommandLine.Model.CommandSpec spec;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.TreeMap;
import java.util.concurrent.Callable;

import io.quarkus.cli.common.HelpOption;
import io.quarkus.cli.common.OutputOptionMixin;
import io.quarkus.cli.common.RunModeOption;
import io.quarkus.cli.common.TargetQuarkusVersionGroup;
Expand Down Expand Up @@ -34,6 +35,9 @@ public class BaseCreateCommand implements Callable<Integer> {
@Mixin
ToggleRegistryClientMixin registryClient;

@CommandLine.Mixin
protected HelpOption helpOption;

@Spec
protected CommandSpec spec;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.concurrent.Callable;

import io.quarkus.cli.common.HelpOption;
import io.quarkus.cli.common.OutputOptionMixin;
import picocli.CommandLine;
import picocli.CommandLine.Mixin;
Expand All @@ -16,6 +17,9 @@ public class BaseRegistryCommand implements Callable<Integer> {
@Mixin
protected RegistryClientMixin registryClient;

@CommandLine.Mixin
protected HelpOption helpOption;

@Spec
protected CommandSpec spec;

Expand Down
68 changes: 57 additions & 11 deletions devtools/cli/src/test/java/io/quarkus/cli/CliHelpTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,117 +24,163 @@ public class CliHelpTest {
public void testCommandHelp() throws Exception {
CliDriver.Result result = CliDriver.execute(workspaceRoot, "--help");
result.echoSystemOut();
Assertions.assertTrue(result.stdout.contains("Usage"), "Help output should show usage instructions");

CliDriver.Result result2 = CliDriver.execute(workspaceRoot);
Assertions.assertEquals(result.stdout, result2.stdout, "Invoking the base command should show usage help");
CliDriver.println("-- same as above\n\n");
}

@Test
@Order(20)
@Order(10)
public void testCreateHelp() throws Exception {
CliDriver.Result result = CliDriver.execute(workspaceRoot, "create", "--help");
result.echoSystemOut();
Assertions.assertTrue(result.stdout.contains("Usage"), "Help output should show usage instructions");
}

@Test
@Order(21)
@Order(11)
public void testCreateAppHelp() throws Exception {
CliDriver.Result result = CliDriver.execute(workspaceRoot, "create", "app", "--help");
result.echoSystemOut();
Assertions.assertTrue(result.stdout.contains("Usage"), "Help output should show usage instructions");
}

@Test
@Order(22)
@Order(12)
public void testCreateCliHelp() throws Exception {
CliDriver.Result result = CliDriver.execute(workspaceRoot, "create", "cli", "--help");
result.echoSystemOut();
Assertions.assertTrue(result.stdout.contains("Usage"), "Help output should show usage instructions");
}

@Test
@Order(23)
@Order(13)
public void testCreateExtensionHelp() throws Exception {
CliDriver.Result result = CliDriver.execute(workspaceRoot, "create", "extension", "--help");
result.echoSystemOut();
Assertions.assertTrue(result.stdout.contains("Usage"), "Help output should show usage instructions");
}

@Test
@Order(30)
@Order(20)
public void testBuildHelp() throws Exception {
CliDriver.Result result = CliDriver.execute(workspaceRoot, "build", "--help");
result.echoSystemOut();
Assertions.assertTrue(result.stdout.contains("Usage"), "Help output should show usage instructions");
}

@Test
@Order(40)
@Order(30)
public void testDevHelp() throws Exception {
CliDriver.Result result = CliDriver.execute(workspaceRoot, "dev", "--help");
result.echoSystemOut();
Assertions.assertTrue(result.stdout.contains("Usage"), "Help output should show usage instructions");
}

@Test
@Order(50)
@Order(40)
public void testExtHelp() throws Exception {
CliDriver.Result result = CliDriver.execute(workspaceRoot, "ext", "--help");
result.echoSystemOut();
Assertions.assertTrue(result.stdout.contains("Usage"), "Help output should show usage instructions");

CliDriver.Result result2 = CliDriver.execute(workspaceRoot, "extension", "--help");
Assertions.assertEquals(result.stdout, result2.stdout, "Help output for command aliases should be the same.");
CliDriver.println("-- same as above\n\n");
}

@Test
@Order(51)
@Order(41)
public void testExtCatHelp() throws Exception {
CliDriver.Result result = CliDriver.execute(workspaceRoot, "ext", "cat", "--help");
result.echoSystemOut();
Assertions.assertTrue(result.stdout.contains("Usage"), "Help output should show usage instructions");

CliDriver.Result result2 = CliDriver.execute(workspaceRoot, "ext", "cat", "--help");
Assertions.assertEquals(result.stdout, result2.stdout, "Help output for command aliases should be the same.");
CliDriver.println("-- same as above\n\n");
}

@Test
@Order(52)
@Order(42)
public void testExtListHelp() throws Exception {
CliDriver.Result result = CliDriver.execute(workspaceRoot, "ext", "ls", "--help");
result.echoSystemOut();
Assertions.assertTrue(result.stdout.contains("Usage"), "Help output should show usage instructions");

CliDriver.Result result2 = CliDriver.execute(workspaceRoot, "ext", "list", "--help");
Assertions.assertEquals(result.stdout, result2.stdout, "Help output for command aliases should be the same.");
CliDriver.println("-- same as above\n\n");
}

@Test
@Order(53)
@Order(43)
public void testExtAddHelp() throws Exception {
CliDriver.Result result = CliDriver.execute(workspaceRoot, "ext", "add", "--help");
result.echoSystemOut();
Assertions.assertTrue(result.stdout.contains("Usage"), "Help output should show usage instructions");
}

@Test
@Order(53)
@Order(44)
public void testExtRemoveHelp() throws Exception {
CliDriver.Result result = CliDriver.execute(workspaceRoot, "ext", "rm", "--help");
result.echoSystemOut();
Assertions.assertTrue(result.stdout.contains("Usage"), "Help output should show usage instructions");

CliDriver.Result result2 = CliDriver.execute(workspaceRoot, "ext", "remove", "--help");
Assertions.assertEquals(result.stdout, result2.stdout, "Help output for command aliases should be the same.");
CliDriver.println("-- same as above\n\n");
}

@Test
@Order(50)
public void testRegistryHelp() throws Exception {
CliDriver.Result result = CliDriver.execute(workspaceRoot, "registry", "--help");
result.echoSystemOut();
Assertions.assertTrue(result.stdout.contains("Usage"), "Help output should show usage instructions");
}

@Test
@Order(51)
public void testRegistryListHelp() throws Exception {
CliDriver.Result result = CliDriver.execute(workspaceRoot, "registry", "list", "--help");
result.echoSystemOut();
Assertions.assertTrue(result.stdout.contains("Usage"), "Help output should show usage instructions");
}

@Test
@Order(51)
public void testRegistryAddHelp() throws Exception {
CliDriver.Result result = CliDriver.execute(workspaceRoot, "registry", "add", "--help");
result.echoSystemOut();
Assertions.assertTrue(result.stdout.contains("Usage"), "Help output should show usage instructions");
}

@Test
@Order(52)
public void testRegistryRemoveHelp() throws Exception {
CliDriver.Result result = CliDriver.execute(workspaceRoot, "registry", "rm", "--help");
result.echoSystemOut();
Assertions.assertTrue(result.stdout.contains("Usage"), "Help output should show usage instructions");
}

@Order(60)
@Test
public void testGenerateCompletionHelp() throws Exception {
CliDriver.Result result = CliDriver.execute(workspaceRoot, "completion", "--help");
result.echoSystemOut();
Assertions.assertTrue(result.stdout.contains("Usage"), "Help output should show usage instructions");
}

@Test
@Order(70)
public void testCommandVersion() throws Exception {
CliDriver.Result result = CliDriver.execute(workspaceRoot, "version", "--help");
result.echoSystemOut();
Assertions.assertTrue(result.stdout.contains("Usage"), "Help output should show usage instructions");
}

@Test
Expand Down

0 comments on commit 917e3d2

Please sign in to comment.