Fix completion with arity != 1

Fixes #24

Handle arrays and primitives
This commit is contained in:
Eric Bottard
2017-05-18 17:01:25 +02:00
parent 1874b7acdb
commit 3b9bbff2f2
4 changed files with 73 additions and 41 deletions

View File

@@ -17,10 +17,11 @@
package org.springframework.shell2.samples.standard;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import java.util.Arrays;
import org.springframework.shell2.standard.ShellComponent;
import org.springframework.shell2.standard.ShellMethod;
import org.springframework.shell2.standard.ShellOption;
/**
* Example commands for the Shell 2 Standard resolver.
@@ -54,4 +55,10 @@ public class Commands {
public void fail(ElementType elementType) {
throw new IllegalArgumentException("You said " + elementType);
}
@ShellMethod(help = "add array numbers")
public double addDoubles(@ShellOption(arity = 3) double[] numbers) {
return Arrays.stream(numbers).sum();
}
}