From 7d08b582224e7e233163c38cdf6a7d2219d36543 Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Thu, 9 Apr 2015 15:08:11 +0200 Subject: [PATCH] Allow library manager to install multiple libraries at once. Libraries are split using a comma fx: --install-library "Kalman filter library,USB Host Shield Library 2.0" --- app/src/processing/app/Base.java | 40 +++++++++++++++++--------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 1b99420eb..f59a1dfa8 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -368,28 +368,30 @@ public class Base { indexer.setLibrariesFolders(BaseNoGui.getLibrariesPath()); installer.updateIndex(); - String[] libraryToInstallParts = parser.getLibraryToInstall().split(":"); + for (String library : parser.getLibraryToInstall().split(",")) { + String[] libraryToInstallParts = library.split(":"); - 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); + 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); } - } - if (selected == null) { - System.out.println(_("Selected library is not available")); - System.exit(1); - } - ContributedLibrary installed = indexer.getIndex().getInstalled(libraryToInstallParts[0]); - if (selected.isReadOnly()) { - installer.remove(installed); - } else { - installer.install(selected, installed); + ContributedLibrary installed = indexer.getIndex().getInstalled(libraryToInstallParts[0]); + if (selected.isReadOnly()) { + installer.remove(installed); + } else { + installer.install(selected, installed); + } } System.exit(0);