Compilation can be customized with the `bench` profile in the manifest.
";
-pub fn execute(options: Options, config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
debug!("executing; cmd=cargo-bench; args={:?}",
env::args().collect::<Vec<_>>());
the --release flag will use the `release` profile instead.
";
-pub fn execute(options: Options, config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
debug!("executing; cmd=cargo-build; args={:?}",
env::args().collect::<Vec<_>>());
config.configure(options.flag_verbose,
fn main() {
env_logger::init().unwrap();
- let config = match Config::default() {
+ let mut config = match Config::default() {
Ok(cfg) => cfg,
Err(e) => {
let mut shell = Shell::new();
})
.collect());
let rest = &args;
- cargo::call_main_without_stdin(execute, &config, USAGE, rest, true)
+ cargo::call_main_without_stdin(execute, &mut config, USAGE, rest, true)
})();
match result {
because they are fundamental (and intertwined). Other commands can rely
on this top-level information.
*/
-fn execute(flags: Flags, config: &Config) -> CliResult {
+fn execute(flags: Flags, config: &mut Config) -> CliResult {
config.configure(flags.flag_verbose,
flags.flag_quiet,
&flags.flag_color,
execute_external_subcommand(config, &args[1], &args)
}
-fn try_execute_builtin_command(config: &Config, args: &[String]) -> Option<CliResult> {
+fn try_execute_builtin_command(config: &mut Config, args: &[String]) -> Option<CliResult> {
macro_rules! cmd {
($name:ident) => (if args[1] == stringify!($name).replace("_", "-") {
config.shell().set_verbosity(Verbosity::Verbose);
- let r = cargo::call_main_without_stdin($name::execute, config,
+ let r = cargo::call_main_without_stdin($name::execute,
+ config,
$name::USAGE,
&args,
false);
flag_z: Vec<String>,
}
-pub fn execute(options: Options, config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
debug!("executing; cmd=cargo-check; args={:?}",
env::args().collect::<Vec<_>>());
and its format, see the `cargo help pkgid` command.
";
-pub fn execute(options: Options, config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
debug!("executing; cmd=cargo-clean; args={:?}", env::args().collect::<Vec<_>>());
config.configure(options.flag_verbose,
options.flag_quiet,
the `cargo help pkgid` command.
";
-pub fn execute(options: Options, config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
debug!("executing; cmd=cargo-check; args={:?}",
env::args().collect::<Vec<_>>());
all updated.
";
-pub fn execute(options: Options, config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
-Z FLAG ... Unstable (nightly-only) flags to Cargo
";
-pub fn execute(options: Options, config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
debug!("executing; cmd=cargo-generate-lockfile; args={:?}", env::args().collect::<Vec<_>>());
config.configure(options.flag_verbose,
options.flag_quiet,
-Z FLAG ... Unstable (nightly-only) flags to Cargo
";
-pub fn execute(options: Options, config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
-h, --help Print this message
";
-pub fn execute(_: Options, _: &Config) -> CliResult {
+pub fn execute(_: Options, _: &mut Config) -> CliResult {
// This is a dummy command just so that `cargo help help` works.
// The actual delegation of help flag to subcommands is handled by the
// cargo command.
-Z FLAG ... Unstable (nightly-only) flags to Cargo
";
-pub fn execute(options: Options, config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
debug!("executing; cmd=cargo-init; args={:?}", env::args().collect::<Vec<_>>());
config.configure(options.flag_verbose,
options.flag_quiet,
The `--list` option will list all installed packages (and their versions).
";
-pub fn execute(options: Options, config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
root: String
}
-pub fn execute(flags: LocateProjectFlags,
- config: &Config) -> CliResult {
+pub fn execute(flags: LocateProjectFlags, config: &mut Config) -> CliResult {
let root = find_root_manifest_for_wd(flags.flag_manifest_path, config.cwd())?;
let string = root.to_str()
";
-pub fn execute(options: Options, config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
-Z FLAG ... Unstable (nightly-only) flags to Cargo
";
-pub fn execute(options: Options, config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
-Z FLAG ... Unstable (nightly-only) flags to Cargo
";
-pub fn execute(options: Options, config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
debug!("executing; cmd=cargo-new; args={:?}", env::args().collect::<Vec<_>>());
config.configure(options.flag_verbose,
options.flag_quiet,
and troubleshooting.
";
-pub fn execute(options: Options, config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
-Z FLAG ... Unstable (nightly-only) flags to Cargo
";
-pub fn execute(options: Options, config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
";
-pub fn execute(options: Options,
- config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
";
-pub fn execute(options: Options, config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
--color WHEN Coloring: auto, always, never
";
-pub fn execute(options: Options, config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
debug!("executing; cmd=cargo-read-manifest; args={:?}",
env::args().collect::<Vec<_>>());
config.shell().set_color_choice(options.flag_color.as_ref().map(|s| &s[..]))?;
the ones before go to Cargo.
";
-pub fn execute(options: Options, config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
`build.rustflags` configuration option.
";
-pub fn execute(options: Options, config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
debug!("executing; cmd=cargo-rustc; args={:?}",
env::args().collect::<Vec<_>>());
config.configure(options.flag_verbose,
the `cargo help pkgid` command.
";
-pub fn execute(options: Options, config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
-Z FLAG ... Unstable (nightly-only) flags to Cargo
";
-pub fn execute(options: Options, config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
cargo test -- --help
";
-pub fn execute(options: Options, config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
debug!("executing; cmd=cargo-test; args={:?}",
env::args().collect::<Vec<_>>());
only uninstall particular binaries.
";
-pub fn execute(options: Options, config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
For more information about package id specifications, see `cargo help pkgid`.
";
-pub fn execute(options: Options, config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
debug!("executing; cmd=cargo-update; args={:?}", env::args().collect::<Vec<_>>());
config.configure(options.flag_verbose,
options.flag_quiet,
-Z FLAG ... Unstable (nightly-only) flags to Cargo
";
-pub fn execute(args: Flags, config: &Config) -> CliResult {
+pub fn execute(args: Flags, config: &mut Config) -> CliResult {
config.configure(args.flag_verbose,
args.flag_quiet,
&args.flag_color,
--color WHEN Coloring: auto, always, never
";
-pub fn execute(_: Options, _: &Config) -> CliResult {
+pub fn execute(_: Options, _: &mut Config) -> CliResult {
debug!("executing; cmd=cargo-version; args={:?}", env::args().collect::<Vec<_>>());
println!("{}", cargo::version());
crates to be locked to any yanked version.
";
-pub fn execute(options: Options, config: &Config) -> CliResult {
+pub fn execute(options: Options, config: &mut Config) -> CliResult {
config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
}
pub fn call_main_without_stdin<'de, Flags: Deserialize<'de>>(
- exec: fn(Flags, &Config) -> CliResult,
- config: &Config,
+ exec: fn(Flags, &mut Config) -> CliResult,
+ config: &mut Config,
usage: &str,
args: &[String],
options_first: bool) -> CliResult
Ok(Config::new(shell, cwd, homedir))
}
+ /// The user's cargo home directory (OS-dependent)
pub fn home(&self) -> &Filesystem { &self.home_path }
+ /// The cargo git directory (`<cargo_home>/git`)
pub fn git_path(&self) -> Filesystem {
self.home_path.join("git")
}
+ /// The cargo registry index directory (`<cargo_home>/registry/index`)
pub fn registry_index_path(&self) -> Filesystem {
self.home_path.join("registry").join("index")
}
+ /// The cargo registry cache directory (`<cargo_home>/registry/path`)
pub fn registry_cache_path(&self) -> Filesystem {
self.home_path.join("registry").join("cache")
}
+ /// The cargo registry source directory (`<cargo_home>/registry/src`)
pub fn registry_source_path(&self) -> Filesystem {
self.home_path.join("registry").join("src")
}
+ /// Get a reference to the shell, for e.g. writing error messages
pub fn shell(&self) -> RefMut<Shell> {
self.shell.borrow_mut()
}
+ /// Get the path to the `rustdoc` executable
pub fn rustdoc(&self) -> CargoResult<&Path> {
self.rustdoc.get_or_try_init(|| self.get_tool("rustdoc")).map(AsRef::as_ref)
}
+ /// Get the path to the `rustc` executable
pub fn rustc(&self) -> CargoResult<&Rustc> {
self.rustc.get_or_try_init(|| Rustc::new(self.get_tool("rustc")?,
self.maybe_get_tool("rustc_wrapper")?))
}
+ /// Get the path to the `cargo` executable
pub fn cargo_exe(&self) -> CargoResult<&Path> {
self.cargo_exe.get_or_try_init(||
env::current_exe().and_then(|path| path.canonicalize())
})
}
- pub fn configure(&self,
+ pub fn configure(&mut self,
verbose: u32,
quiet: Option<bool>,
color: &Option<String>,
!self.frozen.get() && !self.locked.get()
}
+ /// Loads configuration from the filesystem
pub fn load_values(&self) -> CargoResult<HashMap<String, ConfigValue>> {
let mut cfg = CV::Table(HashMap::new(), PathBuf::from("."));
}
}
+ /// Loads credentials config from the credentials file into the ConfigValue object, if present.
fn load_credentials(&self, cfg: &mut ConfigValue) -> CargoResult<()> {
let home_path = self.home_path.clone().into_path_unlocked();
let credentials = home_path.join("credentials");
match (registry, value) {
(&mut CV::Table(ref mut old, _), CV::Table(ref mut new, _)) => {
+ // Take ownership of `new` by swapping it with an empty hashmap, so we can move
+ // into an iterator.
let new = mem::replace(new, HashMap::new());
for (key, value) in new {
old.insert(key, value);