Skip to content

Commit 7d08b58

Browse files
committed
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"
1 parent 87e2e68 commit 7d08b58

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

app/src/processing/app/Base.java

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -368,28 +368,30 @@ protected void onProgress(Progress progress) {
368368
indexer.setLibrariesFolders(BaseNoGui.getLibrariesPath());
369369
installer.updateIndex();
370370

371-
String[] libraryToInstallParts = parser.getLibraryToInstall().split(":");
372-
373-
ContributedLibrary selected=null;
374-
if (libraryToInstallParts.length == 2) {
375-
selected = indexer.getIndex().find(libraryToInstallParts[0], VersionHelper.valueOf(libraryToInstallParts[1]).toString());
376-
} else if (libraryToInstallParts.length == 1) {
377-
List<ContributedLibrary> librariesByName = indexer.getIndex().find(libraryToInstallParts[0]);
378-
Collections.sort(librariesByName, new DownloadableContributionVersionComparator());
379-
if (!librariesByName.isEmpty()) {
380-
selected = librariesByName.get(librariesByName.size() - 1);
371+
for (String library : parser.getLibraryToInstall().split(",")) {
372+
String[] libraryToInstallParts = library.split(":");
373+
374+
ContributedLibrary selected=null;
375+
if (libraryToInstallParts.length == 2) {
376+
selected = indexer.getIndex().find(libraryToInstallParts[0], VersionHelper.valueOf(libraryToInstallParts[1]).toString());
377+
} else if (libraryToInstallParts.length == 1) {
378+
List<ContributedLibrary> librariesByName = indexer.getIndex().find(libraryToInstallParts[0]);
379+
Collections.sort(librariesByName, new DownloadableContributionVersionComparator());
380+
if (!librariesByName.isEmpty()) {
381+
selected = librariesByName.get(librariesByName.size() - 1);
382+
}
383+
}
384+
if (selected == null) {
385+
System.out.println(_("Selected library is not available"));
386+
System.exit(1);
381387
}
382-
}
383-
if (selected == null) {
384-
System.out.println(_("Selected library is not available"));
385-
System.exit(1);
386-
}
387388

388-
ContributedLibrary installed = indexer.getIndex().getInstalled(libraryToInstallParts[0]);
389-
if (selected.isReadOnly()) {
390-
installer.remove(installed);
391-
} else {
392-
installer.install(selected, installed);
389+
ContributedLibrary installed = indexer.getIndex().getInstalled(libraryToInstallParts[0]);
390+
if (selected.isReadOnly()) {
391+
installer.remove(installed);
392+
} else {
393+
installer.install(selected, installed);
394+
}
393395
}
394396

395397
System.exit(0);

0 commit comments

Comments
 (0)