From d022111fde0e71b2309a44fd246e83448ecad84b Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Wed, 8 Apr 2015 15:44:11 +0200 Subject: [PATCH] CLI: library manager install latest if version is not specified --- app/src/processing/app/Base.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index e269f37a4..1fcb91533 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -370,7 +370,16 @@ public class Base { String[] libraryToInstallParts = parser.getLibraryToInstall().split(":"); - ContributedLibrary selected = indexer.getIndex().find(libraryToInstallParts[0], VersionHelper.valueOf(libraryToInstallParts[1]).toString()); + ContributedLibrary selected=null; + if (libraryToInstallParts.length == 2) { + selected = indexer.getIndex().find(libraryToInstallParts[0], VersionHelper.valueOf(libraryToInstallParts[1]).toString()); + } else if (libraryToInstallParts.length == 1) { + List librariesByName = indexer.getIndex().find(libraryToInstallParts[0]); + Collections.sort(librariesByName, new DownloadableContributionVersionComparator()); + if (!librariesByName.isEmpty()) { + selected = librariesByName.get(librariesByName.size() - 1); + } + } if (selected == null) { System.out.println(_("Selected library is not available")); System.exit(1);