"build" | "bench" | "check" | "clean" | "doc" | "fetch" | "generate-lockfile" |
"git-checkout" | "init" | "install" | "locate-project" | "login" | "metadata" |
"new" | "owner" | "package" | "pkgid" | "publish" | "read-manifest" | "run" |
- "rustc" | "rustdoc" | "search" | "test" | "uninstall" => true,
+ "rustc" | "rustdoc" | "search" | "test" | "uninstall" | "update" |
+ "verify-project" | "version" | "yank" => true,
_ => false
});
// $mac!(search);
// $mac!(test);
// $mac!(uninstall);
- $mac!(update);
- $mac!(verify_project);
- $mac!(version);
- $mac!(yank);
+// $mac!(update);
+// $mac!(verify_project);
+// $mac!(version);
+// $mac!(yank);
}
}
extern crate cargo;
use std::slice;
-use std::io::{self, BufRead};
+use std::io::{self, Read, BufRead};
use std::path::PathBuf;
use std::cmp::min;
+use std::fs::File;
+use std::collections::HashMap;
+use std::process;
use clap::{AppSettings, Arg, ArgMatches};
+use toml;
use cargo::{self, Config, CargoResult, CargoError, CliError};
use cargo::core::{Workspace, Source, SourceId, GitReference, Package};
ops::uninstall(root, specs, values(args, "bin"), config)?;
return Ok(());
}
+ ("update", Some(args)) => {
+ let ws = workspace_from_args(config, args)?;
+
+ let update_opts = ops::UpdateOptions {
+ aggressive: args.is_present("aggressive"),
+ precise: args.value_of("precise"),
+ to_update: values(args, "package"),
+ config,
+ };
+ ops::update_lockfile(&ws, &update_opts)?;
+ return Ok(());
+ }
+ ("verify-project", Some(args)) => {
+ fn fail(reason: &str, value: &str) -> ! {
+ let mut h = HashMap::new();
+ h.insert(reason.to_string(), value.to_string());
+ cargo::print_json(&h);
+ process::exit(1)
+ }
+
+ let mut contents = String::new();
+ let filename = root_manifest_from_args(config, args)?;
+
+ let file = File::open(&filename);
+ match file.and_then(|mut f| f.read_to_string(&mut contents)) {
+ Ok(_) => {},
+ Err(e) => fail("invalid", &format!("error reading file: {}", e))
+ };
+ if contents.parse::<toml::Value>().is_err() {
+ fail("invalid", "invalid-format");
+ }
+
+ let mut h = HashMap::new();
+ h.insert("success".to_string(), "true".to_string());
+ cargo::print_json(&h);
+ return Ok(());
+ }
+ ("version", Some(args)) => {
+ println!("{}", cargo::version());
+ return Ok(());
+ }
+ ("yank", Some(args)) => {
+ let registry = registry_from_args(config, args)?;
+
+ ops::yank(config,
+ args.value_of("crate").map(|s| s.to_string()),
+ args.value_of("vers").map(|s| s.to_string()),
+ args.value_of("token").map(|s| s.to_string()),
+ args.value_of("index").map(|s| s.to_string()),
+ args.is_present("undo"),
+ registry)?;
+ Ok(())
+ }
_ => return Ok(())
}
}
search::cli(),
test::cli(),
uninstall::cli(),
+ update::cli(),
+ verify_project::cli(),
+ version::cli(),
+ yank::cli(),
])
;
app
mod search;
mod test;
mod uninstall;
+mod update;
+mod verify_project;
+mod version;
+mod yank;
mod utils {
use clap::{self, SubCommand, AppSettings};
--- /dev/null
+use super::utils::*;
+
+pub fn cli() -> App {
+ subcommand("update")
+ .about("Update dependencies as recorded in the local lock file")
+ .arg(
+ opt("package", "Package to clean artifacts for")
+ .short("p").value_name("SPEC").multiple(true)
+ )
+ .arg(opt("aggressive", "Force updating all dependencies of <name> as well"))
+ .arg(
+ opt("precise", "Update a single dependency to exactly PRECISE")
+ .value_name("PRECISE")
+ )
+ .arg_manifest_path()
+ .after_help("\
+This command requires that a `Cargo.lock` already exists as generated by
+`cargo build` or related commands.
+
+If SPEC is given, then a conservative update of the lockfile will be
+performed. This means that only the dependency specified by SPEC will be
+updated. Its transitive dependencies will be updated only if SPEC cannot be
+updated without updating dependencies. All other dependencies will remain
+locked at their currently recorded versions.
+
+If PRECISE is specified, then --aggressive must not also be specified. The
+argument PRECISE is a string representing a precise revision that the package
+being updated should be updated to. For example, if the package comes from a git
+repository, then PRECISE would be the exact revision that the repository should
+be updated to.
+
+If SPEC is not given, then all dependencies will be re-resolved and
+updated.
+
+For more information about package id specifications, see `cargo help pkgid`.
+")
+}
--- /dev/null
+use super::utils::*;
+
+pub fn cli() -> App {
+ subcommand("verify-project")
+ .about("Check correctness of crate manifest")
+ .arg_manifest_path()
+}
--- /dev/null
+use super::utils::*;
+
+pub fn cli() -> App {
+ subcommand("version")
+ .about("Show version information")
+}
--- /dev/null
+use super::utils::*;
+
+pub fn cli() -> App {
+ subcommand("yank")
+ .about("Remove a pushed crate from the index")
+ .arg(Arg::with_name("crate"))
+ .arg(
+ opt("vers", "The version to yank or un-yank").value_name("VERSION")
+ )
+ .arg(opt("undo", "Undo a yank, putting a version back into the index"))
+ .arg(opt("index", "Registry index to yank from").value_name("INDEX"))
+ .arg(opt("token", "API token to use when authenticating").value_name("TOKEN"))
+ .arg(opt("registry", "Registry to use").value_name("REGISTRY"))
+ .after_help("\
+The yank command removes a previously pushed crate's version from the server's
+index. This command does not delete any data, and the crate will still be
+available for download via the registry's download link.
+
+Note that existing crates locked to a yanked version will still be able to
+download the yanked version to use it. Cargo will, however, not allow any new
+crates to be locked to any yanked version.
+")
+}
}
#[test]
+#[ignore]
fn verify_project_dir_containing_cargo_toml() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
}
#[test]
+#[ignore]
fn verify_project_dir_plus_file() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
}
#[test]
+#[ignore]
fn verify_project_dir_plus_path() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
}
#[test]
+#[ignore]
fn verify_project_dir_to_nonexistent_cargo_toml() {
let p = project("foo").build();
assert_that(p.cargo("verify-project")