use semver::Version;
use tempdir::TempDir;
-use termcolor::Color::Red;
use toml;
use core::{SourceId, Source, Package, Dependency, PackageIdSpec};
let root = resolve_root(root, opts.config)?;
let map = SourceConfigMap::new(opts.config)?;
- if krates.len() <= 1 {
+ let installed_anything = if krates.len() <= 1 {
install_one(root.clone(), map, krates.into_iter().next(), source_id, vers, opts,
- force, true)?;
+ force, true).is_ok()
} else {
let mut succeeded = vec![];
let mut failed = vec![];
first = false;
}
+ let mut summary = vec![];
if !succeeded.is_empty() {
- opts.config.shell().status("Successfully installed", succeeded.join(", "))?;
+ summary.push(format!("Successfully installed {}!", succeeded.join(", ")));
}
if !failed.is_empty() {
- opts.config.shell().status_with_color("Failed to install", failed.join(", "), Red)?;
+ summary.push(format!("Failed to install {} (see error(s) above).", failed.join(", ")));
}
- }
+ if !succeeded.is_empty() || !failed.is_empty() {
+ opts.config.shell().status("\nSummary:", summary.join(" "))?;
+ }
+
+ !succeeded.is_empty()
+ };
- // Print a warning that if this directory isn't in PATH that they won't be
- // able to run these commands.
- let dst = metadata(opts.config, &root)?.parent().join("bin");
- let path = env::var_os("PATH").unwrap_or(OsString::new());
- for path in env::split_paths(&path) {
- if path == dst {
- return Ok(())
+ if installed_anything {
+ // Print a warning that if this directory isn't in PATH that they won't be
+ // able to run these commands.
+ let dst = metadata(opts.config, &root)?.parent().join("bin");
+ let path = env::var_os("PATH").unwrap_or(OsString::new());
+ for path in env::split_paths(&path) {
+ if path == dst {
+ return Ok(())
+ }
}
- }
- opts.config.shell().warn(&format!("be sure to add `{}` to your PATH to be \
- able to run the installed binaries",
- dst.display()))?;
+ opts.config.shell().warn(&format!("be sure to add `{}` to your PATH to be \
+ able to run the installed binaries",
+ dst.display()))?;
+ }
Ok(())
}
#[test]
fn multiple_pkgs() {
pkg("foo", "0.0.1");
- pkg("bar", "0.0.1");
+ pkg("bar", "0.0.2");
- assert_that(cargo_process("install").arg("foo").arg("bar"),
+ assert_that(cargo_process("install").args(&["foo", "bar", "baz"]),
execs().with_status(0).with_stderr(&format!("\
[UPDATING] registry `[..]`
[DOWNLOADING] foo v0.0.1 (registry file://[..])
[COMPILING] foo v0.0.1
[FINISHED] release [optimized] target(s) in [..]
[INSTALLING] {home}[..]bin[..]foo[..]
-[DOWNLOADING] bar v0.0.1 (registry file://[..])
-[INSTALLING] bar v0.0.1
-[COMPILING] bar v0.0.1
+[DOWNLOADING] bar v0.0.2 (registry file://[..])
+[INSTALLING] bar v0.0.2
+[COMPILING] bar v0.0.2
[FINISHED] release [optimized] target(s) in [..]
[INSTALLING] {home}[..]bin[..]bar[..]
-Successfully installed foo, bar
+error: could not find `baz` in `registry [..]`
+
+Summary: Successfully installed foo, bar! Failed to install baz (see error(s) above).
warning: be sure to add `[..]` to your PATH to be able to run the installed binaries
",
home = cargo_home().display())));