|
23 | 23 | //
|
24 | 24 | package cloud.commandframework;
|
25 | 25 |
|
| 26 | +import cloud.commandframework.arguments.CommandArgument; |
26 | 27 | import cloud.commandframework.arguments.compound.ArgumentTriplet;
|
27 | 28 | import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
28 | 29 | import cloud.commandframework.arguments.standard.BooleanArgument;
|
|
37 | 38 | import java.util.Arrays;
|
38 | 39 | import java.util.Collections;
|
39 | 40 | import java.util.List;
|
| 41 | +import org.junit.Ignore; |
40 | 42 | import org.junit.jupiter.api.Assertions;
|
41 | 43 | import org.junit.jupiter.api.BeforeAll;
|
| 44 | +import org.junit.jupiter.api.Disabled; |
42 | 45 | import org.junit.jupiter.api.Test;
|
43 | 46 |
|
44 | 47 | import static cloud.commandframework.util.TestUtils.createManager;
|
@@ -635,6 +638,41 @@ void testFlagYieldingStringArrayWithLiberalFlagArgument() {
|
635 | 638 | assertThat(suggestions6).isEmpty();
|
636 | 639 | }
|
637 | 640 |
|
| 641 | + @Test |
| 642 | + void testTextFlagCompletion() { |
| 643 | + // Arrange |
| 644 | + final CommandManager<TestCommandSender> manager = createManager(); |
| 645 | + manager.setSetting(CommandManager.ManagerSettings.LIBERAL_FLAG_PARSING, true); |
| 646 | + manager.command( |
| 647 | + manager.commandBuilder("command") |
| 648 | + .flag(manager.flagBuilder("flag").withAliases("f") |
| 649 | + .withArgument(EnumArgument.of(TestEnum.class, "test")).build()) |
| 650 | + .flag(manager.flagBuilder("flog").build()) |
| 651 | + ); |
| 652 | + |
| 653 | + // Act |
| 654 | + final List<String> suggestions1 = suggest(manager, "command "); |
| 655 | + final List<String> suggestions2 = suggest(manager, "command --"); |
| 656 | + final List<String> suggestions3 = suggest(manager, "command --f"); |
| 657 | + final List<String> suggestions4 = suggest(manager, "command --fla"); |
| 658 | + final List<String> suggestions5 = suggest(manager, "command -f"); |
| 659 | + final List<String> suggestions6 = suggest(manager, "command -"); |
| 660 | + |
| 661 | + final List<String> suggestions7 = suggest(manager, "command -f "); |
| 662 | + final List<String> suggestions8 = suggest(manager, "command -f b"); |
| 663 | + |
| 664 | + // Assert |
| 665 | + assertThat(suggestions1).containsExactly("--flag", "--flog", "-f"); |
| 666 | + assertThat(suggestions2).containsExactly("--flag", "--flog"); |
| 667 | + assertThat(suggestions3).containsExactly("--flag", "--flog"); |
| 668 | + assertThat(suggestions4).containsExactly("--flag"); |
| 669 | + assertThat(suggestions5).containsExactly("-f"); |
| 670 | + assertThat(suggestions6).containsExactly("--flag", "--flog", "-f"); |
| 671 | + assertThat(suggestions7).containsExactly("foo", "bar"); |
| 672 | + assertThat(suggestions8).containsExactly("bar"); |
| 673 | + } |
| 674 | + |
| 675 | + |
638 | 676 | private List<String> suggest(CommandManager<TestCommandSender> manager, String command) {
|
639 | 677 | return manager.suggest(new TestCommandSender(), command);
|
640 | 678 | }
|
|
0 commit comments