diff --git a/spring-shell-docs/src/main/asciidoc/using-spring-shell.adoc b/spring-shell-docs/src/main/asciidoc/using-spring-shell.adoc index d4de557c..747aab9c 100644 --- a/spring-shell-docs/src/main/asciidoc/using-spring-shell.adoc +++ b/spring-shell-docs/src/main/asciidoc/using-spring-shell.adoc @@ -348,9 +348,30 @@ shell:>add --numbers 1 --numbers 2 --numbers 3.3 ==== ===== -===== Infinite Arity +===== Varying Amount Arity -TO BE IMPLEMENTED +The above example demonstrates requiring a known, constant arity for a parameter, three in this case. Allowing any number of multiple values of a parameter can be achieved by leaving `arity` unspecified and using Spring's built-in comma separated value parsing for collections and/or arrays: +[source, java] +---- + @ShellMethod("Add a Varying Amount of Numbers.") + public double add(@ShellOption double[] numbers) { + return Arrays.stream(numbers).sum(); + } +---- + +The command may then be invoked with any amount of `numbers`: + +==== +[source] +---- +shell:>add 1,2,3.3 +6.3 +shell:>add --numbers 42 +42.0 +shell:>add --numbers 1,2,3.3,4,5 +15.3 +---- +==== ===== Special Handling of Boolean Parameters