Skip to content

Provide actual string to findPlatform for Optional<Version> #8069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@

import org.apache.commons.compress.utils.IOUtils;
import org.apache.commons.lang3.StringUtils;

import com.github.zafarkhaja.semver.Version;

import processing.app.debug.TargetBoard;
import processing.app.debug.TargetPackage;
import processing.app.debug.TargetPlatform;
Expand Down Expand Up @@ -71,6 +74,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static processing.app.I18n.format;
import static processing.app.I18n.tr;


Expand Down Expand Up @@ -305,7 +309,12 @@ public Base(String[] args) throws Exception {

ContributedPlatform selected = null;
if (boardToInstallParts.length == 3) {
selected = indexer.getIndex().findPlatform(boardToInstallParts[0], boardToInstallParts[1], VersionHelper.valueOf(boardToInstallParts[2]).toString());
Optional<Version> version = VersionHelper.valueOf(boardToInstallParts[2]);
if (!version.isPresent()) {
System.out.println(format(tr("Invalid version {0}"), boardToInstallParts[2]));
System.exit(1);
}
selected = indexer.getIndex().findPlatform(boardToInstallParts[0], boardToInstallParts[1], version.get().toString());
} else if (boardToInstallParts.length == 2) {
List<ContributedPlatform> platformsByName = indexer.getIndex().findPlatforms(boardToInstallParts[0], boardToInstallParts[1]);
Collections.sort(platformsByName, new DownloadableContributionVersionComparator());
Expand Down Expand Up @@ -346,7 +355,12 @@ public Base(String[] args) throws Exception {

ContributedLibrary selected = null;
if (libraryToInstallParts.length == 2) {
selected = indexer.getIndex().find(libraryToInstallParts[0], VersionHelper.valueOf(libraryToInstallParts[1]).toString());
Optional<Version> version = VersionHelper.valueOf(libraryToInstallParts[1]);
if (!version.isPresent()) {
System.out.println(format(tr("Invalid version {0}"), libraryToInstallParts[1]));
System.exit(1);
}
selected = indexer.getIndex().find(libraryToInstallParts[0], version.get().toString());
} else if (libraryToInstallParts.length == 1) {
List<ContributedLibrary> librariesByName = indexer.getIndex().find(libraryToInstallParts[0]);
Collections.sort(librariesByName, new DownloadableContributionVersionComparator());
Expand Down