1 package com.lexicalscope.jewel.cli.examples;
2
3 import static com.lexicalscope.jewel.cli.CliFactory.createCli;
4 import static org.hamcrest.MatcherAssert.assertThat;
5 import static org.hamcrest.Matchers.*;
6
7 import org.junit.Test;
8
9 import com.lexicalscope.jewel.cli.Option;
10 import com.lexicalscope.jewel.cli.Unparsed;
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 public class TestHelpMessages {
29 interface OptionWithDefault
30 {
31 @Option(defaultValue = "3")
32 int getMyOption();
33
34 @Option(helpRequest = true)
35 boolean getHelp();
36 }
37
38 @Test public void optionWithDefaultShowAsOptional()
39 {
40 assertThat(createCli(OptionWithDefault.class).getHelpMessage(), containsString("[--myOption value]"));
41 }
42
43 interface HiddenOptionNotIncludedInHelp
44 {
45 @Option(hidden = true)
46 int getMyOption();
47 }
48
49 @Test public void hiddenOptionNotIncludedInHelp()
50 {
51 assertThat(createCli(HiddenOptionNotIncludedInHelp.class).getHelpMessage(), not(containsString("myOption")));
52 }
53
54 interface HiddenUnparsedOptionNotIncludedInHelp
55 {
56 @Unparsed(hidden = true)
57 int getMyOption();
58 }
59
60 @Test public void hiddenUnparsedOptionNotIncludedInHelp()
61 {
62 assertThat(createCli(HiddenUnparsedOptionNotIncludedInHelp.class).getHelpMessage(), not(containsString("ARGUMENTS")));
63 }
64 }