CLI: Board and Lib Manager, syntax change: --install-boards (plural) and arduino:avr:1.6.2 (with the arch, not the name of the selected platform)

This commit is contained in:
Federico Fissore 2015-04-09 13:03:41 +02:00
parent 6d46bd0bde
commit 87e2e68b85
4 changed files with 17 additions and 35 deletions

View File

@ -59,28 +59,6 @@ public abstract class ContributedPackage {
return null; return null;
} }
/**
* Return the latest version available of a platform
*
* @param platform
* @return
*/
public ContributedPlatform findPlatform(String platform) {
VersionComparator version = new VersionComparator();
ContributedPlatform found = null;
for (ContributedPlatform p : getPlatforms()) {
if (!p.getName().equals(platform))
continue;
if (found == null) {
found = p;
continue;
}
if (version.compare(p.getParsedVersion(), found.getParsedVersion()) > 0)
found = p;
}
return found;
}
public ContributedTool findTool(String name, String version) { public ContributedTool findTool(String name, String version) {
for (ContributedTool tool : getTools()) { for (ContributedTool tool : getTools()) {
if (tool.getName().equals(name) && tool.getVersion().equals(version)) if (tool.getName().equals(name) && tool.getVersion().equals(version))

View File

@ -50,8 +50,8 @@ public abstract class ContributionsIndex {
return null; return null;
} }
public List<ContributedPlatform> findPlatforms(String packageName, final String platformName) { public List<ContributedPlatform> findPlatforms(String packageName, final String platformArch) {
if (packageName == null || platformName == null) { if (packageName == null || platformArch == null) {
return null; return null;
} }
@ -62,19 +62,19 @@ public abstract class ContributionsIndex {
Collection<ContributedPlatform> platforms = Collections2.filter(aPackage.getPlatforms(), new Predicate<ContributedPlatform>() { Collection<ContributedPlatform> platforms = Collections2.filter(aPackage.getPlatforms(), new Predicate<ContributedPlatform>() {
@Override @Override
public boolean apply(ContributedPlatform contributedPlatform) { public boolean apply(ContributedPlatform contributedPlatform) {
return platformName.equals(contributedPlatform.getName()); return platformArch.equals(contributedPlatform.getArchitecture());
} }
}); });
return Lists.newLinkedList(platforms); return Lists.newLinkedList(platforms);
} }
public ContributedPlatform findPlatform(String packageName, final String platformName, final String platformVersion) { public ContributedPlatform findPlatform(String packageName, final String platformArch, final String platformVersion) {
if (platformVersion == null) { if (platformVersion == null) {
return null; return null;
} }
Collection<ContributedPlatform> platformsByName = findPlatforms(packageName, platformName); Collection<ContributedPlatform> platformsByName = findPlatforms(packageName, platformArch);
if (platformsByName == null) { if (platformsByName == null) {
return null; return null;
} }
@ -92,8 +92,8 @@ public abstract class ContributionsIndex {
return platforms.iterator().next(); return platforms.iterator().next();
} }
public ContributedPlatform getInstalled(String packageName, String platformName) { public ContributedPlatform getInstalled(String packageName, String platformArch) {
List<ContributedPlatform> installedPlatforms = new LinkedList<ContributedPlatform>(Collections2.filter(findPlatforms(packageName, platformName), new InstalledPredicate())); List<ContributedPlatform> installedPlatforms = new LinkedList<ContributedPlatform>(Collections2.filter(findPlatforms(packageName, platformArch), new InstalledPredicate()));
Collections.sort(installedPlatforms, new DownloadableContributionBuiltInAtTheBottomComparator()); Collections.sort(installedPlatforms, new DownloadableContributionBuiltInAtTheBottomComparator());
if (installedPlatforms.isEmpty()) { if (installedPlatforms.isEmpty()) {

View File

@ -19,7 +19,7 @@ import static processing.app.I18n._;
public class CommandlineParser { public class CommandlineParser {
private enum ACTION { private enum ACTION {
GUI, NOOP, VERIFY("--verify"), UPLOAD("--upload"), GET_PREF("--get-pref"), INSTALL_BOARD("--install-board"), INSTALL_LIBRARY("--install-library"); GUI, NOOP, VERIFY("--verify"), UPLOAD("--upload"), GET_PREF("--get-pref"), INSTALL_BOARD("--install-boards"), INSTALL_LIBRARY("--install-library");
private final String value; private final String value;
@ -58,7 +58,7 @@ public class CommandlineParser {
actions.put("--verify", ACTION.VERIFY); actions.put("--verify", ACTION.VERIFY);
actions.put("--upload", ACTION.UPLOAD); actions.put("--upload", ACTION.UPLOAD);
actions.put("--get-pref", ACTION.GET_PREF); actions.put("--get-pref", ACTION.GET_PREF);
actions.put("--install-board", ACTION.INSTALL_BOARD); actions.put("--install-boards", ACTION.INSTALL_BOARD);
actions.put("--install-library", ACTION.INSTALL_LIBRARY); actions.put("--install-library", ACTION.INSTALL_LIBRARY);
// Check if any files were passed in on the command line // Check if any files were passed in on the command line

View File

@ -29,7 +29,7 @@ SYNOPSIS
*arduino* [*--get-pref* __preference__] *arduino* [*--get-pref* __preference__]
*arduino* [*--install-board* __package name__:__platform name__[:__version__]] *arduino* [*--install-boards* __package name__:__platform architecture__[:__version__]]
*arduino* [*--install-library* __library name__[:__version__]] *arduino* [*--install-library* __library name__[:__version__]]
@ -68,7 +68,7 @@ ACTIONS
stream. When the value does not exist, nothing is printed and stream. When the value does not exist, nothing is printed and
the exit status is set (see EXIT STATUS below). the exit status is set (see EXIT STATUS below).
*--install-board* __package name__:__platform name__[:__version__]:: *--install-boards* __package name__:__platform architecture__[:__version__]::
Fetches available board support (platform) list and install the specified one, along with its related tools. If __version__ is omitted, the latest is installed. If a platform with the same version is already installed, nothing is installed and program exits with exit code 1. If a platform with a different version is already installed, it's replaced. Fetches available board support (platform) list and install the specified one, along with its related tools. If __version__ is omitted, the latest is installed. If a platform with the same version is already installed, nothing is installed and program exits with exit code 1. If a platform with a different version is already installed, it's replaced.
*--install-library* __library name__[:__version__]:: *--install-library* __library name__[:__version__]::
@ -249,7 +249,11 @@ Change the selected board and build path and do nothing else.
Install latest SAM board support Install latest SAM board support
arduino --install-board "arduino:Arduino SAM Boards (32-bits ARM Cortex-M3)" arduino --install-boards "arduino:sam"
Install AVR board support, 1.6.2
arduino --install-boards "arduino:avr:1.6.2"
Install Bridge library version 1.0.0 Install Bridge library version 1.0.0
@ -285,7 +289,7 @@ HISTORY
Introduced *--save-prefs*. Introduced *--save-prefs*.
1.6.4:: 1.6.4::
Introduced *--install-board* and *--install-library*. Introduced *--install-boards* and *--install-library*.
{empty}:: {empty}::
*--pref* options are now not saved to the preferences file, just *--pref* options are now not saved to the preferences file, just