Skip to content

Commit

Permalink
#412 simplify code a little and add entry to RELEASE-NOTES.md
Browse files Browse the repository at this point in the history
Closes #412.
  • Loading branch information
remkop committed Jul 19, 2018
1 parent 1cfcddb commit a5f1dd0
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 22 deletions.
33 changes: 33 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
# picocli Release Notes

# <a name="3.3.1"></a> Picocli 3.3.1 (UNRELEASED)
The picocli community is pleased to announce picocli 3.3.1.

This release contains a bugfix and enhancements.

This is the thirty-fifth public release.
Picocli follows [semantic versioning](http://semver.org/).

## <a name="3.3.1"></a> Table of Contents
* [New and noteworthy](#3.3.1-new)
* [Promoted features](#3.3.1-promoted)
* [Fixed issues](#3.3.1-fixes)
* [Deprecations](#3.3.1-deprecated)
* [Potential breaking changes](#3.3.1-breaking-changes)

## <a name="3.3.1-new"></a> New and Noteworthy

## <a name="3.3.1-promoted"></a> Promoted Features
Promoted features are features that were incubating in previous versions of picocli but are now supported and subject to backwards compatibility.

No features have been promoted in this picocli release.

## <a name="3.3.1-fixes"></a> Fixed issues
- [#412] Enhancement: Enum constant names are now returned from `ArgSpec::completionCandidates()`. Thanks to [Radovan Panák](https://github.com/rpanak).
- [#417] Enhancement: Ensure bash scripts have correct line separators. Thanks to [Holger Stenger](https://github.com/stengerh).

## <a name="3.3.1-deprecated"></a> Deprecations
No features were deprecated in this release.

## <a name="3.3.1-breaking-changes"></a> Potential breaking changes
This release has no breaking changes.


# <a name="3.3.0"></a> Picocli 3.3.0
The picocli community is pleased to announce picocli 3.3.0.

Expand Down
33 changes: 11 additions & 22 deletions src/main/java/picocli/CommandLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -3830,7 +3830,6 @@ private ArgSpec(Builder builder) {
paramLabel = empty(builder.paramLabel) ? "PARAM" : builder.paramLabel;
converters = builder.converters == null ? new ITypeConverter<?>[0] : builder.converters;
showDefaultValue = builder.showDefaultValue == null ? Help.Visibility.ON_DEMAND : builder.showDefaultValue;
completionCandidates = builder.completionCandidates;
hidden = builder.hidden;
required = builder.required && builder.defaultValue == null; //#261 not required if it has a default
defaultValue = builder.defaultValue;
Expand Down Expand Up @@ -3878,6 +3877,13 @@ private ArgSpec(Builder builder) {
} else {
auxiliaryTypes = builder.auxiliaryTypes;
}
if (builder.completionCandidates == null && type.isEnum()) {
List<String> list = new ArrayList<String>();
for (Object c : type.getEnumConstants()) { list.add(c.toString()); }
completionCandidates = Collections.unmodifiableList(list);
} else {
completionCandidates = builder.completionCandidates;
}
}

/** Returns whether this is a required option or positional parameter.
Expand All @@ -3894,11 +3900,10 @@ private ArgSpec(Builder builder) {
public String[] renderedDescription() {
if (description == null || description.length == 0) { return description; }
StringBuilder candidates = new StringBuilder();
final Iterable<String> resolvedCompletionCandidates = completionCandidates();
if (resolvedCompletionCandidates != null) {
for (String candidate : resolvedCompletionCandidates) {
if (completionCandidates() != null) {
for (String c : completionCandidates()) {
if (candidates.length() > 0) { candidates.append(", "); }
candidates.append(candidate);
candidates.append(c);
}
}
String defaultValueString = defaultValueString = String.valueOf(defaultValue != null ? defaultValue : initialValue);
Expand Down Expand Up @@ -3959,23 +3964,7 @@ public String[] renderedDescription() {
* @return the completion candidates for this option or positional parameter, valid enum constant names,
* or {@code null}
* @since 3.2 */
public Iterable<String> completionCandidates() {
if (completionCandidates != null) {
final List<String> ret = new LinkedList<String>();
for (String completionCandidate : completionCandidates) {
ret.add(completionCandidate);
}
return ret;
} else if (type != null && type.isEnum()) {
final List<String> ret = new LinkedList<String>();

for (Object enumConstant : type.getEnumConstants()) {
ret.add(enumConstant.toString());
}
return ret;
}
return null;
}
public Iterable<String> completionCandidates() { return completionCandidates; }

/** Returns the {@link IGetter} that is responsible for supplying the value of this argument. */
public IGetter getter() { return getter; }
Expand Down

0 comments on commit a5f1dd0

Please sign in to comment.