|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2021 the original author or authors. |
|
|
|
* Copyright 2002-2023 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -46,7 +46,11 @@ import org.springframework.util.StringUtils; |
|
|
|
* // ...
|
|
|
|
* // ...
|
|
|
|
* }</pre> |
|
|
|
* }</pre> |
|
|
|
* |
|
|
|
* |
|
|
|
* See {@link CommandLinePropertySource} for complete general usage examples. |
|
|
|
* <p>If an option has several representations, the most descriptive is expected |
|
|
|
|
|
|
|
* to be set last, and is used as the property name of the associated |
|
|
|
|
|
|
|
* {@link EnumerablePropertySource#getPropertyNames()}. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <p>See {@link CommandLinePropertySource} for complete general usage examples. |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>Requires JOpt Simple version 4.3 or higher. Tested against JOpt up until 5.0. |
|
|
|
* <p>Requires JOpt Simple version 4.3 or higher. Tested against JOpt up until 5.0. |
|
|
|
* |
|
|
|
* |
|
|
|
@ -88,9 +92,9 @@ public class JOptCommandLinePropertySource extends CommandLinePropertySource<Opt |
|
|
|
public String[] getPropertyNames() { |
|
|
|
public String[] getPropertyNames() { |
|
|
|
List<String> names = new ArrayList<>(); |
|
|
|
List<String> names = new ArrayList<>(); |
|
|
|
for (OptionSpec<?> spec : this.source.specs()) { |
|
|
|
for (OptionSpec<?> spec : this.source.specs()) { |
|
|
|
|
|
|
|
// Last option is expected to be the most descriptive.
|
|
|
|
String lastOption = CollectionUtils.lastElement(spec.options()); |
|
|
|
String lastOption = CollectionUtils.lastElement(spec.options()); |
|
|
|
if (lastOption != null) { |
|
|
|
if (lastOption != null) { |
|
|
|
// Only the longest name is used for enumerating
|
|
|
|
|
|
|
|
names.add(lastOption); |
|
|
|
names.add(lastOption); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|