Document bean validation constraints in help()

Fixes #147
This commit is contained in:
Eric Bottard
2017-09-08 14:19:01 +02:00
parent 665f319d5f
commit 32c18bec75
10 changed files with 307 additions and 120 deletions

View File

@@ -47,6 +47,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.FileCopyUtils;
import org.springframework.util.ReflectionUtils;
import javax.validation.constraints.Max;
/**
* Tests for the {@link Help} command.
*
@@ -133,7 +135,8 @@ public class HelpTest {
// Multiple keys and arity 0. Help displayed on next line
@ShellOption(help = "Do not ask for confirmation. YOLO", arity = 0, value = {"-f", "--force"}) boolean force,
// Single key, arity >= 1. Help displayed on next line. Optional
@ShellOption(help = "The answer to everything", defaultValue = "42", value = "-n") int n,
// Also, bears bean validation annotation
@ShellOption(help = "The answer to everything", defaultValue = "42", value = "-n") @Max(5) int n,
// Single key, arity > 1.
@ShellOption(help = "Some other parameters", arity = 3, value = "-o") float[] o
) {

View File

@@ -1,23 +1,28 @@
&
&
NAME&
first-command - A rather extensive description of some command.&
&
SYNOPSYS&
first-command [-r] [-f] [[-n] int] [-o] float float float &
&
OPTIONS&
-r Whether to delete recursively [Optional, default = false]&
&
-f or --force&
Do not ask for confirmation. YOLO [Optional, default = false]&
&
-n int&
The answer to everything [Optional, default = 42]&
&
-o float float float&
Some other parameters [Mandatory]&
&
ALSO KNOWN AS&
1st-command&
&
NAME
first-command - A rather extensive description of some command.
SYNOPSYS
first-command [-r] [-f] [[-n] int] [-o] float float float
OPTIONS
-r Whether to delete recursively
[Optional, default = false]
-f or --force
Do not ask for confirmation. YOLO
[Optional, default = false]
-n int
The answer to everything
[Optional, default = 42]
[must be less than or equal to 5]
-o float float float
Some other parameters
[Mandatory]
ALSO KNOWN AS
1st-command