CLI: library manager install latest if version is not specified

This commit is contained in:
Federico Fissore 2015-04-08 15:44:11 +02:00
parent ba3ecff13c
commit d022111fde
1 changed files with 10 additions and 1 deletions

View File

@ -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<ContributedLibrary> 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);