1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
package com.lexicalscope.jewel.cli.validation; |
6 | |
|
7 | |
import com.lexicalscope.jewel.cli.HelpRequestedException; |
8 | |
import com.lexicalscope.jewel.cli.specification.OptionsSpecification; |
9 | |
import com.lexicalscope.jewel.cli.specification.ParsedOptionSpecification; |
10 | |
|
11 | |
import org.hamcrest.Description; |
12 | |
import org.hamcrest.TypeSafeMatcher; |
13 | |
|
14 | 232 | public class RejectHelpOption extends TypeSafeMatcher<ParsedOptionSpecification> |
15 | |
{ |
16 | |
private final OptionsSpecification<?> specification; |
17 | |
|
18 | |
public RejectHelpOption(final OptionsSpecification<?> specification) |
19 | 226 | { |
20 | 226 | this.specification = specification; |
21 | 226 | } |
22 | |
|
23 | |
@Override |
24 | |
public void describeTo(final Description description) |
25 | |
{ |
26 | 0 | description.appendText("non help option"); |
27 | 0 | } |
28 | |
|
29 | |
@Override |
30 | |
protected boolean matchesSafely(final ParsedOptionSpecification item) |
31 | |
{ |
32 | 232 | if(item.isHelpOption()) |
33 | |
{ |
34 | 4 | throw new HelpRequestedException(specification); |
35 | |
} |
36 | 228 | return true; |
37 | |
} |
38 | |
} |