Print documentation for flags

After writing a flag on the shell, pressing "tab" will print out the
documentation for that flag.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191899137
This commit is contained in:
guyben 2018-04-06 09:38:22 -07:00 committed by Ben McIlwain
parent 6699915132
commit 6d5f7dc4a1
2 changed files with 174 additions and 48 deletions

View file

@ -134,9 +134,29 @@ public class ShellCommandTest {
performJCommanderCompletorTest("help testCommand ", 0);
}
@Test
public void testCompletion_documentation() throws Exception {
performJCommanderCompletorTest(
"testCommand ",
0,
"",
"Main parameter: normal argument\n (java.util.List<java.lang.String>)\n");
performJCommanderCompletorTest("testAnotherCommand ", 0, "", "Main parameter: [None]\n");
performJCommanderCompletorTest(
"testCommand -x ", 0, "", "Flag documentation: test parameter\n (java.lang.String)\n");
performJCommanderCompletorTest(
"testAnotherCommand -x ", 0, "", "Flag documentation: [No documentation available]\n");
performJCommanderCompletorTest(
"testCommand x ",
0,
"",
"Main parameter: normal argument\n (java.util.List<java.lang.String>)\n");
performJCommanderCompletorTest("testAnotherCommand x ", 0, "", "Main parameter: [None]\n");
}
@Test
public void testCompletion_arguments() throws Exception {
performJCommanderCompletorTest("testCommand ", 0, "-x ", "--xparam ", "--xorg ");
performJCommanderCompletorTest("testCommand -", 1, "-x ", "--xparam ", "--xorg ");
performJCommanderCompletorTest("testCommand --wrong", 7);
performJCommanderCompletorTest("testCommand noise --", 2, "--xparam ", "--xorg ");
performJCommanderCompletorTest("testAnotherCommand --o", 3);