From 4e625feb03d1700f577a524fd4dfd8ce145593de Mon Sep 17 00:00:00 2001 From: Janne Valkealahti Date: Fri, 29 Apr 2022 15:55:21 +0100 Subject: [PATCH] Drop jcommander - Fixes #395 --- pom.xml | 13 -- spring-shell-autoconfigure/pom.xml | 10 -- ...derParameterResolverAutoConfiguration.java | 39 ----- spring-shell-docs/pom.xml | 10 -- spring-shell-jcommander-adapter/pom.xml | 40 ----- .../JCommanderParameterResolver.java | 158 ------------------ .../shell/jcommander/package-info.java | 22 --- .../META-INF/native-image/reflect-config.json | 18 -- .../shell/jcommander/FieldCollins.java | 64 ------- .../JCommanderParameterResolverTest.java | 117 ------------- .../shell/jcommander/MyLordCommands.java | 40 ----- spring-shell-samples/pom.xml | 4 - .../shell/samples/jcommander/Args.java | 55 ------ .../jcommander/JCommanderCommands.java | 36 ---- spring-shell-starter/pom.xml | 4 - 15 files changed, 630 deletions(-) delete mode 100644 spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/JCommanderParameterResolverAutoConfiguration.java delete mode 100644 spring-shell-jcommander-adapter/pom.xml delete mode 100644 spring-shell-jcommander-adapter/src/main/java/org/springframework/shell/jcommander/JCommanderParameterResolver.java delete mode 100644 spring-shell-jcommander-adapter/src/main/java/org/springframework/shell/jcommander/package-info.java delete mode 100644 spring-shell-jcommander-adapter/src/main/resources/META-INF/native-image/reflect-config.json delete mode 100644 spring-shell-jcommander-adapter/src/test/java/org/springframework/shell/jcommander/FieldCollins.java delete mode 100644 spring-shell-jcommander-adapter/src/test/java/org/springframework/shell/jcommander/JCommanderParameterResolverTest.java delete mode 100644 spring-shell-jcommander-adapter/src/test/java/org/springframework/shell/jcommander/MyLordCommands.java delete mode 100644 spring-shell-samples/src/main/java/org/springframework/shell/samples/jcommander/Args.java delete mode 100644 spring-shell-samples/src/main/java/org/springframework/shell/samples/jcommander/JCommanderCommands.java diff --git a/pom.xml b/pom.xml index 9c033c28..8d89382c 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,6 @@ 3.21.0 - 1.81 4.3.1 1.2 @@ -33,7 +32,6 @@ spring-shell-core-test-support spring-shell-standard spring-shell-standard-commands - spring-shell-jcommander-adapter spring-shell-table spring-shell-docs spring-shell-dependencies @@ -64,11 +62,6 @@ spring-shell-standard-commands 2.1.0-SNAPSHOT - - org.springframework.shell - spring-shell-jcommander-adapter - 2.1.0-SNAPSHOT - org.springframework.shell spring-shell-starter @@ -100,12 +93,6 @@ ${jline.version} true - - com.beust - jcommander - ${jcommander.version} - true - org.antlr ST4 diff --git a/spring-shell-autoconfigure/pom.xml b/spring-shell-autoconfigure/pom.xml index e2dc9644..b9bbb77f 100644 --- a/spring-shell-autoconfigure/pom.xml +++ b/spring-shell-autoconfigure/pom.xml @@ -26,16 +26,6 @@ spring-shell-standard-commands true - - com.beust - jcommander - true - - - org.springframework.shell - spring-shell-jcommander-adapter - true - org.springframework.boot spring-boot-starter-test diff --git a/spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/JCommanderParameterResolverAutoConfiguration.java b/spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/JCommanderParameterResolverAutoConfiguration.java deleted file mode 100644 index e33d07b3..00000000 --- a/spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/JCommanderParameterResolverAutoConfiguration.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2017-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.shell.boot; - -import com.beust.jcommander.JCommander; - -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.context.annotation.Configuration; -import org.springframework.shell.jcommander.JCommanderParameterResolver; -import org.springframework.context.annotation.Bean; - -/** - * Registers JCommanderParameterResolver and supporting beans as appropriate. - * - * @author Eric Bottard - */ -@Configuration(proxyBeanMethods = false) -@ConditionalOnClass({ JCommander.class, JCommanderParameterResolver.class }) -public class JCommanderParameterResolverAutoConfiguration { - - @Bean - public JCommanderParameterResolver jCommanderParameterResolver() { - return new JCommanderParameterResolver(); - } -} diff --git a/spring-shell-docs/pom.xml b/spring-shell-docs/pom.xml index 84e44658..a63f6301 100644 --- a/spring-shell-docs/pom.xml +++ b/spring-shell-docs/pom.xml @@ -38,16 +38,6 @@ spring-shell-standard-commands provided - - org.springframework.shell - spring-shell-jcommander-adapter - provided - - - com.beust - jcommander - provided - org.springframework.shell spring-shell-table diff --git a/spring-shell-jcommander-adapter/pom.xml b/spring-shell-jcommander-adapter/pom.xml deleted file mode 100644 index 180b6d8b..00000000 --- a/spring-shell-jcommander-adapter/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - 4.0.0 - - spring-shell-jcommander-adapter - Spring Shell JCommander Adapter - jar - - - org.springframework.shell - spring-shell-parent - 2.1.0-SNAPSHOT - - - Adapter classes to allow JCommander type annotations and parsing via Spring Shell 2 - - - - org.springframework.shell - spring-shell-core - - - com.beust - jcommander - true - - - org.springframework.boot - spring-boot-starter-test - test - - - org.assertj - assertj-core - test - - - - - diff --git a/spring-shell-jcommander-adapter/src/main/java/org/springframework/shell/jcommander/JCommanderParameterResolver.java b/spring-shell-jcommander-adapter/src/main/java/org/springframework/shell/jcommander/JCommanderParameterResolver.java deleted file mode 100644 index 00b32086..00000000 --- a/spring-shell-jcommander-adapter/src/main/java/org/springframework/shell/jcommander/JCommanderParameterResolver.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright 2015-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.shell.jcommander; - -import java.lang.annotation.Annotation; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import javax.validation.Validator; -import javax.validation.ValidatorFactory; -import javax.validation.metadata.BeanDescriptor; - -import com.beust.jcommander.DynamicParameter; -import com.beust.jcommander.JCommander; -import com.beust.jcommander.Parameter; -import com.beust.jcommander.ParameterException; -import com.beust.jcommander.ParametersDelegate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.MethodParameter; -import org.springframework.shell.CompletionContext; -import org.springframework.shell.CompletionProposal; -import org.springframework.shell.ParameterDescription; -import org.springframework.shell.ParameterResolver; -import org.springframework.shell.Utils; -import org.springframework.shell.ValueResult; -import org.springframework.util.ReflectionUtils; - -import static org.springframework.shell.Utils.unCamelify; - -/** - * Provides integration with JCommander. - * - * @author Eric Bottard - * @author Josh Long - */ -public class JCommanderParameterResolver implements ParameterResolver { - - private final static Logger log = LoggerFactory.getLogger(JCommanderParameterResolver.class); - private static final Collection> JCOMMANDER_ANNOTATIONS = Arrays.asList(Parameter.class, - DynamicParameter.class, ParametersDelegate.class); - - private Validator validator = Utils.defaultValidator(); - - @Autowired(required = false) - public void setValidatorFactory(ValidatorFactory validatorFactory) { - this.validator = validatorFactory.getValidator(); - } - - @Override - public boolean supports(MethodParameter parameter) { - AtomicBoolean isSupported = new AtomicBoolean(false); - Class parameterType = parameter.getParameterType(); - - log.debug("isLegalReflectiveAccess before"); - ReflectionUtils.doWithFields(parameterType, field -> { - ReflectionUtils.makeAccessible(field); - boolean hasAnnotation = Arrays.stream(field.getAnnotations()) - .map(Annotation::annotationType) - .anyMatch(JCOMMANDER_ANNOTATIONS::contains); - isSupported.compareAndSet(false, hasAnnotation); - log.debug("isLegalReflectiveAccess fields {}", hasAnnotation); - }); - - ReflectionUtils.doWithMethods(parameterType, method -> { - ReflectionUtils.makeAccessible(method); - boolean hasAnnotation = Arrays.stream(method.getAnnotations()) - .map(Annotation::annotationType) - .anyMatch(Parameter.class::equals); - isSupported.compareAndSet(false, hasAnnotation); - log.debug("isLegalReflectiveAccess methods {}", hasAnnotation); - }); - log.debug("isLegalReflectiveAccess supports {}", isSupported.get()); - return isSupported.get(); - } - - @Override - public ValueResult resolve(MethodParameter methodParameter, List words) { - JCommander jCommander = createJCommander(methodParameter); - jCommander.parse(words.toArray(new String[words.size()])); - return new ValueResult(methodParameter, jCommander.getObjects().get(0)); - } - - private JCommander createJCommander(MethodParameter methodParameter) { - Object pojo = BeanUtils.instantiateClass(methodParameter.getParameterType()); - return new JCommander(pojo); - } - - @Override - public Stream describe(MethodParameter parameter) { - JCommander jCommander = createJCommander(parameter); - Stream jCommanderDescriptions = streamAllJCommanderDescriptions( - jCommander); - - BeanDescriptor constraintsForClass = validator.getConstraintsForClass(parameter.getParameterType()); - - return jCommanderDescriptions - .map(j -> new ParameterDescription(parameter, - unCamelify(j.getParameterized().getType().getSimpleName())) - .keys(Arrays.asList(j.getParameter().names())) - .help(j.getDescription()) - .mandatoryKey(!j.equals(jCommander.getMainParameterValue())) - // Not ideal as this does not take reverse-conversion into account, but just toString() - .defaultValue(j.getDefault() == null ? "" : String.valueOf(j.getDefault())) - .elementDescriptor( - constraintsForClass.getConstraintsForProperty(j.getParameterized().getName()))); - } - - /** - * Return all JCommander parameter descriptions, including the "main" parameter - * if present. - */ - private Stream streamAllJCommanderDescriptions(JCommander jCommander) { - return Stream.concat( - jCommander.getParameters().stream(), - jCommander.getMainParameterValue() != null ? Stream.of(jCommander.getMainParameterValue()) : Stream.empty()); - } - - @Override - public List complete(MethodParameter parameter, CompletionContext context) { - JCommander jCommander = createJCommander(parameter); - List words = context.getWords(); - try { - jCommander.parseWithoutValidation(words.toArray(new String[words.size()])); - } - catch (ParameterException ignored) { - // Exception here certainly means current buffer is not parseable in full. - // Better to bail out now. - return Collections.emptyList(); - } - return streamAllJCommanderDescriptions(jCommander) - .filter(p -> !p.isAssigned()) - .flatMap(p -> Arrays.stream(p.getParameter().names())) - .map(CompletionProposal::new) - .collect(Collectors.toList()); - } -} diff --git a/spring-shell-jcommander-adapter/src/main/java/org/springframework/shell/jcommander/package-info.java b/spring-shell-jcommander-adapter/src/main/java/org/springframework/shell/jcommander/package-info.java deleted file mode 100644 index b3e867ad..00000000 --- a/spring-shell-jcommander-adapter/src/main/java/org/springframework/shell/jcommander/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2017 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Provides integration with JCommander. - * - * @author Eric Bottard - */ -package org.springframework.shell.jcommander; diff --git a/spring-shell-jcommander-adapter/src/main/resources/META-INF/native-image/reflect-config.json b/spring-shell-jcommander-adapter/src/main/resources/META-INF/native-image/reflect-config.json deleted file mode 100644 index 3c883bcc..00000000 --- a/spring-shell-jcommander-adapter/src/main/resources/META-INF/native-image/reflect-config.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "name":"com.beust.jcommander.JCommander" - }, - { - "name":"com.beust.jcommander.converters.IntegerConverter", - "queryAllDeclaredConstructors":true, - "methods":[{"name":"","parameterTypes":["java.lang.String"] }] - }, - { - "name":"com.beust.jcommander.validators.NoValidator", - "methods":[{"name":"","parameterTypes":[] }] - }, - { - "name":"com.beust.jcommander.validators.NoValueValidator", - "methods":[{"name":"","parameterTypes":[] }] - } -] diff --git a/spring-shell-jcommander-adapter/src/test/java/org/springframework/shell/jcommander/FieldCollins.java b/spring-shell-jcommander-adapter/src/test/java/org/springframework/shell/jcommander/FieldCollins.java deleted file mode 100644 index 1313dea3..00000000 --- a/spring-shell-jcommander-adapter/src/test/java/org/springframework/shell/jcommander/FieldCollins.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.shell.jcommander; - -import java.util.ArrayList; -import java.util.List; - -import com.beust.jcommander.Parameter; - -/** - * A POJO with fields annotated with JCommander annotations. - * - * @author Eric Bottard - * @see MyLordCommands#genesis(FieldCollins) - */ -public class FieldCollins { - - @Parameter(names = {"--name", "-n"}, description = "what's in a name?") - private String name; - - @Parameter(names = "-level") - private int level = 3; - - @Parameter(description = "rest") - private List rest = new ArrayList<>(); - - public List getRest() { - return rest; - } - - public void setRest(List rest) { - this.rest = rest; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getLevel() { - return level; - } - - public void setLevel(int level) { - this.level = level; - } -} diff --git a/spring-shell-jcommander-adapter/src/test/java/org/springframework/shell/jcommander/JCommanderParameterResolverTest.java b/spring-shell-jcommander-adapter/src/test/java/org/springframework/shell/jcommander/JCommanderParameterResolverTest.java deleted file mode 100644 index e2e5dace..00000000 --- a/spring-shell-jcommander-adapter/src/test/java/org/springframework/shell/jcommander/JCommanderParameterResolverTest.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2015-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.shell.jcommander; - -import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.Collections; -import java.util.stream.Stream; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledOnJre; -import org.junit.jupiter.api.condition.JRE; - -import org.springframework.core.MethodParameter; -import org.springframework.shell.CompletionContext; -import org.springframework.shell.CompletionProposal; -import org.springframework.shell.ParameterDescription; -import org.springframework.shell.Utils; -import org.springframework.util.ReflectionUtils; - -import static java.util.Arrays.asList; -import static java.util.Collections.singletonList; -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Unit test for {@link JCommanderParameterResolver}. - * - * @author Eric Bottard - * @author Florent Biville - */ -public class JCommanderParameterResolverTest { - - private static final Method COMMAND_METHOD = ReflectionUtils.findMethod(MyLordCommands.class, "genesis", FieldCollins.class); - - private JCommanderParameterResolver resolver = new JCommanderParameterResolver(); - - @Test - @DisabledOnJre({JRE.JAVA_17}) - public void testSupportsJCommanderPojos() throws Exception { - assertThat(resolver.supports(Utils.createMethodParameter(COMMAND_METHOD, 0))).isEqualTo(true); - } - - @Test - @DisabledOnJre({JRE.JAVA_17}) - public void testDoesNotSupportsNonJCommanderPojos() throws Exception { - Method method = ReflectionUtils.findMethod(MyLordCommands.class, "apocalypse", String.class); - - assertThat(resolver.supports(Utils.createMethodParameter(method, 0))).isFalse(); - } - - @Test - public void testPojoValuesAreCorrectlySet() { - MethodParameter methodParameter = Utils.createMethodParameter(COMMAND_METHOD, 0); - - FieldCollins resolved = (FieldCollins) resolver - .resolve(methodParameter, asList("--name foo -level 2 something-else yet-something-else".split(" "))) - .resolvedValue(); - - assertThat(resolved.getName()).isEqualTo("foo"); - assertThat(resolved.getLevel()).isEqualTo(2); - assertThat(resolved.getRest()).containsOnlyOnce("something-else", "yet-something-else"); - } - - @Test - public void testDescribe() { - MethodParameter methodParameter = Utils.createMethodParameter(COMMAND_METHOD, 0); - - Stream desciptions = resolver.describe(methodParameter); - ParameterDescription name = new ParameterDescription(methodParameter, "string") - .keys(Arrays.asList("--name", "-n")) - .help("what's in a name?") - .defaultValue(""); - ParameterDescription level = new ParameterDescription(methodParameter, "int") - .keys(singletonList("-level")) - .defaultValue("3"); - ParameterDescription rest = new ParameterDescription(methodParameter, "list") - .defaultValue("[]") - .mandatoryKey(false) - .help("rest"); - assertThat(desciptions).contains(name, level, rest); - } - - @Test - public void testCanComplete() { - MethodParameter methodParameter = Utils.createMethodParameter(COMMAND_METHOD, 0); - - CompletionContext context = new CompletionContext(Collections.emptyList(), 0, 0); - Stream proposals = resolver.complete(methodParameter, context).stream().map(CompletionProposal::value); - assertThat(proposals).containsExactly("--name", "-n", "-level"); - - context = new CompletionContext(Arrays.asList("-n", "foo"), 0, 0); - proposals = resolver.complete(methodParameter, context).stream().map(CompletionProposal::value); - assertThat(proposals).containsExactly("-level"); - } - - @Test - public void testCannotComplete() { - MethodParameter methodParameter = Utils.createMethodParameter(COMMAND_METHOD, 0); - - CompletionContext context = new CompletionContext(Arrays.asList("--name"), 0, 0); - Stream proposals = resolver.complete(methodParameter, context).stream().map(CompletionProposal::value); - assertThat(proposals).isEmpty(); - } -} diff --git a/spring-shell-jcommander-adapter/src/test/java/org/springframework/shell/jcommander/MyLordCommands.java b/spring-shell-jcommander-adapter/src/test/java/org/springframework/shell/jcommander/MyLordCommands.java deleted file mode 100644 index 4c75d1d4..00000000 --- a/spring-shell-jcommander-adapter/src/test/java/org/springframework/shell/jcommander/MyLordCommands.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.shell.jcommander; - -/** - * An hypothetical command class, with one method using JCommander args, and the other not. - * - * @author Eric Bottard - */ -public class MyLordCommands { - - /** - * This method should be supported. - */ - public void genesis(FieldCollins fieldCollins) { - - } - - /** - * This method is not. - */ - public void apocalypse(String param) { - - } - -} diff --git a/spring-shell-samples/pom.xml b/spring-shell-samples/pom.xml index 6a0f8917..67cab079 100644 --- a/spring-shell-samples/pom.xml +++ b/spring-shell-samples/pom.xml @@ -39,10 +39,6 @@ org.springframework.shell spring-shell-starter - - com.beust - jcommander - diff --git a/spring-shell-samples/src/main/java/org/springframework/shell/samples/jcommander/Args.java b/spring-shell-samples/src/main/java/org/springframework/shell/samples/jcommander/Args.java deleted file mode 100644 index 774853d4..00000000 --- a/spring-shell-samples/src/main/java/org/springframework/shell/samples/jcommander/Args.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2017 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.shell.samples.jcommander; - -import java.util.ArrayList; -import java.util.List; - -import javax.validation.constraints.Min; - -import com.beust.jcommander.Parameter; - -/** - * An example straight from the JCommander documentation. - * - * @author Eric Bottard - * @author Cédric Beust - */ -public class Args { - - @Parameter - private List parameters = new ArrayList<>(); - - @Min(3) - @Parameter(names = { "-log", "-verbose" }, description = "Level of verbosity") - private Integer verbose = 1; - - @Parameter(names = "-groups", description = "Comma-separated list of group names to be run") - private String groups; - - @Parameter(names = "-debug", description = "Debug mode") - private boolean debug = false; - - @Override - public String toString() { - return "Args{" + - "parameters=" + parameters + - ", verbose=" + verbose + - ", groups='" + groups + '\'' + - ", debug=" + debug + - '}'; - } -} diff --git a/spring-shell-samples/src/main/java/org/springframework/shell/samples/jcommander/JCommanderCommands.java b/spring-shell-samples/src/main/java/org/springframework/shell/samples/jcommander/JCommanderCommands.java deleted file mode 100644 index e9d4d1e1..00000000 --- a/spring-shell-samples/src/main/java/org/springframework/shell/samples/jcommander/JCommanderCommands.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2017 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.shell.samples.jcommander; - -import org.springframework.shell.standard.ShellComponent; -import org.springframework.shell.standard.ShellMethod; -import org.springframework.shell.standard.ShellOption; - -import javax.validation.Valid; - -/** - * A class with JCommander commands. - * - * @author Eric Bottard - */ -@ShellComponent -public class JCommanderCommands { - - @ShellMethod("Bind parameters to JCommander POJO.") - public String jcommander(@ShellOption(optOut = true) @Valid Args args) { - return "You said " + args; - } -} diff --git a/spring-shell-starter/pom.xml b/spring-shell-starter/pom.xml index 33135e96..b163b0af 100644 --- a/spring-shell-starter/pom.xml +++ b/spring-shell-starter/pom.xml @@ -30,10 +30,6 @@ org.springframework.shell spring-shell-standard-commands - - org.springframework.shell - spring-shell-jcommander-adapter - org.springframework.shell spring-shell-table