]> git.proxmox.com Git - cargo.git/commitdiff
Add configuration keys for -v, --color
authorAlex Crichton <alex@alexcrichton.com>
Fri, 19 Feb 2016 07:26:25 +0000 (23:26 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 26 Feb 2016 19:42:31 +0000 (11:42 -0800)
This commit adds configuration keys for:

    [term]
    verbose = true
    color = 'auto'

These are all meant to be proxies for the command line flags but configured on a
global basis if desired.

29 files changed:
src/bin/bench.rs
src/bin/build.rs
src/bin/cargo.rs
src/bin/clean.rs
src/bin/doc.rs
src/bin/fetch.rs
src/bin/generate_lockfile.rs
src/bin/git_checkout.rs
src/bin/init.rs
src/bin/install.rs
src/bin/login.rs
src/bin/metadata.rs
src/bin/new.rs
src/bin/owner.rs
src/bin/package.rs
src/bin/pkgid.rs
src/bin/publish.rs
src/bin/run.rs
src/bin/rustc.rs
src/bin/rustdoc.rs
src/bin/search.rs
src/bin/test.rs
src/bin/uninstall.rs
src/bin/update.rs
src/bin/verify_project.rs
src/bin/yank.rs
src/cargo/util/config.rs
src/cargo/util/errors.rs
src/doc/config.md

index 96203de1ad71e928a8dc4fee189f65f1408b90cb..2dd2399ed691ac9e82835a013e9dd2c5d4e7ceeb 100644 (file)
@@ -11,8 +11,8 @@ pub struct Options {
     flag_no_default_features: bool,
     flag_target: Option<String>,
     flag_manifest_path: Option<String>,
-    flag_verbose: bool,
-    flag_quiet: bool,
+    flag_verbose: Option<bool>,
+    flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_lib: bool,
     flag_bin: Vec<String>,
@@ -63,8 +63,9 @@ Compilation can be customized with the `bench` profile in the manifest.
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd()));
-    try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
-    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
+    try!(config.configure_shell(options.flag_verbose,
+                                options.flag_quiet,
+                                &options.flag_color));
 
     let ops = ops::TestOptions {
         no_run: options.flag_no_run,
index be550f47569ec9027ebb5143433229a858b50a78..5a66ca754965223f2296f220ac769316bf4d89e0 100644 (file)
@@ -13,8 +13,8 @@ pub struct Options {
     flag_no_default_features: bool,
     flag_target: Option<String>,
     flag_manifest_path: Option<String>,
-    flag_verbose: bool,
-    flag_quiet: bool,
+    flag_verbose: Option<bool>,
+    flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_release: bool,
     flag_lib: bool,
@@ -61,8 +61,9 @@ the --release flag will use the `release` profile instead.
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     debug!("executing; cmd=cargo-build; args={:?}",
            env::args().collect::<Vec<_>>());
-    try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
-    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
+    try!(config.configure_shell(options.flag_verbose,
+                                options.flag_quiet,
+                                &options.flag_color));
 
     let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd()));
 
index 9011ca1fe599ee1a45a74bcaacd7bbd757a97ec6..4ffa5ea8acf233b048aa1416dee49eabe607e3d1 100644 (file)
@@ -16,9 +16,9 @@ use cargo::util::{self, CliResult, lev_distance, Config, human, CargoResult, Cha
 #[derive(RustcDecodable)]
 pub struct Flags {
     flag_list: bool,
-    flag_verbose: bool,
     flag_version: bool,
-    flag_quiet: bool,
+    flag_verbose: Option<bool>,
+    flag_quiet: Option<bool>,
     flag_color: Option<String>,
     arg_command: String,
     arg_args: Vec<String>,
@@ -108,8 +108,9 @@ mod subcommands {
   on this top-level information.
 */
 fn execute(flags: Flags, config: &Config) -> CliResult<Option<()>> {
-    try!(config.shell().set_verbosity(flags.flag_verbose, flags.flag_quiet));
-    try!(config.shell().set_color_config(flags.flag_color.as_ref().map(|s| &s[..])));
+    try!(config.configure_shell(flags.flag_verbose,
+                                flags.flag_quiet,
+                                &flags.flag_color));
 
     init_git_transports(config);
     cargo::util::job::setup();
index fa3ef0e50aeec70009cc560095762c507b46301c..5bcb10aeb25602dc2a5ef64c3473e39fb8c94af8 100644 (file)
@@ -9,8 +9,8 @@ pub struct Options {
     flag_package: Vec<String>,
     flag_target: Option<String>,
     flag_manifest_path: Option<String>,
-    flag_verbose: bool,
-    flag_quiet: bool,
+    flag_verbose: Option<bool>,
+    flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_release: bool,
 }
@@ -38,9 +38,10 @@ and its format, see the `cargo help pkgid` command.
 ";
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
-    try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
-    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
     debug!("executing; cmd=cargo-clean; args={:?}", env::args().collect::<Vec<_>>());
+    try!(config.configure_shell(options.flag_verbose,
+                                options.flag_quiet,
+                                &options.flag_color));
 
     let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd()));
     let opts = ops::CleanOptions {
index 4907575f27648a482eed60c09c1fc227c9fb2e3d..3cb732738095a68befa27923abb6b5ada0de2425 100644 (file)
@@ -11,9 +11,9 @@ pub struct Options {
     flag_no_default_features: bool,
     flag_no_deps: bool,
     flag_open: bool,
-    flag_verbose: bool,
     flag_release: bool,
-    flag_quiet: bool,
+    flag_verbose: Option<bool>,
+    flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_package: Vec<String>,
 }
@@ -49,8 +49,9 @@ the `cargo help pkgid` command.
 ";
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
-    try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
-    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
+    try!(config.configure_shell(options.flag_verbose,
+                                options.flag_quiet,
+                                &options.flag_color));
 
     let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd()));
 
index cd17ef9b5b534ed8dc3144edb592714b5b40673c..1f32e8741549a5b139ce8e25afffce468c83e1f7 100644 (file)
@@ -5,8 +5,8 @@ use cargo::util::important_paths::find_root_manifest_for_wd;
 #[derive(RustcDecodable)]
 pub struct Options {
     flag_manifest_path: Option<String>,
-    flag_verbose: bool,
-    flag_quiet: bool,
+    flag_verbose: Option<bool>,
+    flag_quiet: Option<bool>,
     flag_color: Option<String>,
 }
 
@@ -34,8 +34,9 @@ all updated.
 ";
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
-    try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
-    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
+    try!(config.configure_shell(options.flag_verbose,
+                                options.flag_quiet,
+                                &options.flag_color));
     let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd()));
     try!(ops::fetch(&root, config));
     Ok(None)
index 197a2319aca8f4f3a8aa60e76fdddb1a89bc01d5..7e50eff265f7c0e4279fa4d1127cb4a098835670 100644 (file)
@@ -7,8 +7,8 @@ use cargo::util::important_paths::find_root_manifest_for_wd;
 #[derive(RustcDecodable)]
 pub struct Options {
     flag_manifest_path: Option<String>,
-    flag_verbose: bool,
-    flag_quiet: bool,
+    flag_verbose: Option<bool>,
+    flag_quiet: Option<bool>,
     flag_color: Option<String>,
 }
 
@@ -28,8 +28,9 @@ Options:
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     debug!("executing; cmd=cargo-generate-lockfile; args={:?}", env::args().collect::<Vec<_>>());
-    try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
-    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
+    try!(config.configure_shell(options.flag_verbose,
+                                options.flag_quiet,
+                                &options.flag_color));
     let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd()));
 
     try!(ops::generate_lockfile(&root, config));
index 1aa13bc6e412b5c5f1d6e1b2041c57d244bbf7b8..a453055147c6cc5c8b6aad8e96d4003d865782be 100644 (file)
@@ -6,8 +6,8 @@ use cargo::util::{Config, CliResult, CliError, human, ToUrl};
 pub struct Options {
     flag_url: String,
     flag_reference: String,
-    flag_verbose: bool,
-    flag_quiet: bool,
+    flag_verbose: Option<bool>,
+    flag_quiet: Option<bool>,
     flag_color: Option<String>,
 }
 
@@ -26,8 +26,9 @@ Options:
 ";
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
-    try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
-    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
+    try!(config.configure_shell(options.flag_verbose,
+                                options.flag_quiet,
+                                &options.flag_color));
     let Options { flag_url: url, flag_reference: reference, .. } = options;
 
     let url = try!(url.to_url().map_err(|e| {
index cfc2b11d47e365440f81ea3a34b7a32efdb1e045..8856f8b35996a9d225a314859ff2c1f9d5de2456 100644 (file)
@@ -5,8 +5,8 @@ use cargo::util::{CliResult, Config};
 
 #[derive(RustcDecodable)]
 pub struct Options {
-    flag_verbose: bool,
-    flag_quiet: bool,
+    flag_verbose: Option<bool>,
+    flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_bin: bool,
     arg_path: Option<String>,
@@ -35,8 +35,9 @@ Options:
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     debug!("executing; cmd=cargo-init; args={:?}", env::args().collect::<Vec<_>>());
-    try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
-    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
+    try!(config.configure_shell(options.flag_verbose,
+                                options.flag_quiet,
+                                &options.flag_color));
 
     let Options { flag_bin, arg_path, flag_name, flag_vcs, .. } = options;
 
index ece80f44c53f4f52a60540913cdc4c0d75a51fb7..bd2c3191bf3e340667a029abe89824b5a77be549 100644 (file)
@@ -10,8 +10,8 @@ pub struct Options {
     flag_debug: bool,
     flag_bin: Vec<String>,
     flag_example: Vec<String>,
-    flag_verbose: bool,
-    flag_quiet: bool,
+    flag_verbose: Option<bool>,
+    flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_root: Option<String>,
     flag_list: bool,
@@ -83,8 +83,9 @@ The `--list` option will list all installed packages (and their versions).
 ";
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
-    try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
-    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
+    try!(config.configure_shell(options.flag_verbose,
+                                options.flag_quiet,
+                                &options.flag_color));
 
     let compile_opts = ops::CompileOptions {
         config: config,
index 70ef64d8e7953229b0c2106b01948bb3eb6edb54..bfb8418e40e8d5f707f6dfd56acfb179b6378da8 100644 (file)
@@ -10,8 +10,8 @@ use cargo::util::{CliResult, Config, human, ChainError};
 pub struct Options {
     flag_host: Option<String>,
     arg_token: Option<String>,
-    flag_verbose: bool,
-    flag_quiet: bool,
+    flag_verbose: Option<bool>,
+    flag_quiet: Option<bool>,
     flag_color: Option<String>,
 }
 
@@ -31,8 +31,9 @@ Options:
 ";
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
-    try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
-    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
+    try!(config.configure_shell(options.flag_verbose,
+                                options.flag_quiet,
+                                &options.flag_color));
     let token = match options.arg_token.clone() {
         Some(token) => token,
         None => {
index 9093a1a78b5818854968ee431b997853aa22f4c7..c8375d95c95116c6f768abaa5df6f716297689e3 100644 (file)
@@ -15,8 +15,8 @@ pub struct Options {
     flag_manifest_path: Option<String>,
     flag_no_default_features: bool,
     flag_no_deps: bool,
-    flag_quiet: bool,
-    flag_verbose: bool,
+    flag_quiet: Option<bool>,
+    flag_verbose: Option<bool>,
 }
 
 pub const USAGE: &'static str = "
@@ -41,8 +41,9 @@ Options:
 ";
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<ExportInfo>> {
-    try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
-    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
+    try!(config.configure_shell(options.flag_verbose,
+                                options.flag_quiet,
+                                &options.flag_color));
     let manifest = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd()));
 
     let options = OutputMetadataOptions {
index ba392132277fc1ac19bea072c4499a7fd3498c9d..340fab90b4eee146b22469a0cd938b9f1f02eecd 100644 (file)
@@ -5,8 +5,8 @@ use cargo::util::{CliResult, Config};
 
 #[derive(RustcDecodable)]
 pub struct Options {
-    flag_verbose: bool,
-    flag_quiet: bool,
+    flag_verbose: Option<bool>,
+    flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_bin: bool,
     arg_path: String,
@@ -35,8 +35,9 @@ Options:
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     debug!("executing; cmd=cargo-new; args={:?}", env::args().collect::<Vec<_>>());
-    try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
-    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
+    try!(config.configure_shell(options.flag_verbose,
+                                options.flag_quiet,
+                                &options.flag_color));
 
     let Options { flag_bin, arg_path, flag_name, flag_vcs, .. } = options;
 
index 40d4e20b9ff4023fffdb5a378135824aa06f8a34..33f49e51140a1a708b2d3a8131dfc964299cafc5 100644 (file)
@@ -8,8 +8,8 @@ pub struct Options {
     flag_add: Option<Vec<String>>,
     flag_remove: Option<Vec<String>>,
     flag_index: Option<String>,
-    flag_verbose: bool,
-    flag_quiet: bool,
+    flag_verbose: Option<bool>,
+    flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_list: bool,
 }
@@ -41,8 +41,9 @@ and troubleshooting.
 ";
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
-    try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
-    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
+    try!(config.configure_shell(options.flag_verbose,
+                                options.flag_quiet,
+                                &options.flag_color));
     let opts = ops::OwnersOptions {
         krate: options.arg_crate,
         token: options.flag_token,
index c9bb161ef5150909ea64b57ccd966f3060bca9d8..37dd9a122d402d71952bc4d7bcb4a4bc1885215a 100644 (file)
@@ -4,8 +4,8 @@ use cargo::util::important_paths::find_root_manifest_for_wd;
 
 #[derive(RustcDecodable)]
 pub struct Options {
-    flag_verbose: bool,
-    flag_quiet: bool,
+    flag_verbose: Option<bool>,
+    flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_manifest_path: Option<String>,
     flag_no_verify: bool,
@@ -32,8 +32,9 @@ Options:
 ";
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
-    try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
-    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
+    try!(config.configure_shell(options.flag_verbose,
+                                options.flag_quiet,
+                                &options.flag_color));
     let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd()));
     try!(ops::package(&root, config,
                       !options.flag_no_verify,
index 7a88b290589200ab8a51c0838b945bbc81e1cdc4..68e53236f20fe0cfe0b380497702faab999ef10f 100644 (file)
@@ -4,8 +4,8 @@ use cargo::util::important_paths::{find_root_manifest_for_wd};
 
 #[derive(RustcDecodable)]
 pub struct Options {
-    flag_verbose: bool,
-    flag_quiet: bool,
+    flag_verbose: Option<bool>,
+    flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_manifest_path: Option<String>,
     arg_spec: Option<String>,
@@ -47,8 +47,9 @@ Example Package IDs
 
 pub fn execute(options: Options,
                config: &Config) -> CliResult<Option<()>> {
-    try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
-    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
+    try!(config.configure_shell(options.flag_verbose,
+                                options.flag_quiet,
+                                &options.flag_color));
     let root = try!(find_root_manifest_for_wd(options.flag_manifest_path.clone(), config.cwd()));
 
     let spec = options.arg_spec.as_ref().map(|s| &s[..]);
index cf8f8f9040ed3ae76b3de1d644c7b139398e4f76..dac40fae3e2c367ca3aff462e42701b4859c91af 100644 (file)
@@ -7,8 +7,8 @@ pub struct Options {
     flag_host: Option<String>,
     flag_token: Option<String>,
     flag_manifest_path: Option<String>,
-    flag_verbose: bool,
-    flag_quiet: bool,
+    flag_verbose: Option<bool>,
+    flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_no_verify: bool,
 }
@@ -32,8 +32,9 @@ Options:
 ";
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
-    try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
-    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
+    try!(config.configure_shell(options.flag_verbose,
+                                options.flag_quiet,
+                                &options.flag_color));
     let Options {
         flag_token: token,
         flag_host: host,
index 1926bbf21bd8c0bd4a5e754c908f222106730250..34f83c669415534820c46408191f361a51dd3180 100644 (file)
@@ -11,8 +11,8 @@ pub struct Options {
     flag_no_default_features: bool,
     flag_target: Option<String>,
     flag_manifest_path: Option<String>,
-    flag_verbose: bool,
-    flag_quiet: bool,
+    flag_verbose: Option<bool>,
+    flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_release: bool,
     arg_args: Vec<String>,
@@ -49,8 +49,9 @@ the ones before go to Cargo.
 ";
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
-    try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
-    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
+    try!(config.configure_shell(options.flag_verbose,
+                                options.flag_quiet,
+                                &options.flag_color));
 
     let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd()));
 
index 3337ffcff4e87d78b120fa1cbd60b270286ab3a7..fc4b89790faa0ea521d9b89a54b923ef3e4f5565 100644 (file)
@@ -14,8 +14,8 @@ pub struct Options {
     flag_no_default_features: bool,
     flag_target: Option<String>,
     flag_manifest_path: Option<String>,
-    flag_verbose: bool,
-    flag_quiet: bool,
+    flag_verbose: Option<bool>,
+    flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_release: bool,
     flag_lib: bool,
@@ -66,8 +66,9 @@ must be used to select which target is compiled.
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     debug!("executing; cmd=cargo-rustc; args={:?}",
            env::args().collect::<Vec<_>>());
-    try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
-    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
+    try!(config.configure_shell(options.flag_verbose,
+                                options.flag_quiet,
+                                &options.flag_color));
 
     let root = try!(find_root_manifest_for_wd(options.flag_manifest_path,
                                               config.cwd()));
index 9949c24c1e95e584b91db4e4c2a9d20d7f51c768..ed53d769ba8b18f86ce663fe034ef6ad19316202 100644 (file)
@@ -11,9 +11,9 @@ pub struct Options {
     flag_manifest_path: Option<String>,
     flag_no_default_features: bool,
     flag_open: bool,
-    flag_verbose: bool,
+    flag_verbose: Option<bool>,
     flag_release: bool,
-    flag_quiet: bool,
+    flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_package: Option<String>,
     flag_lib: bool,
@@ -62,8 +62,9 @@ the `cargo help pkgid` command.
 ";
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
-    try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
-    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
+    try!(config.configure_shell(options.flag_verbose,
+                                options.flag_quiet,
+                                &options.flag_color));
 
     let root = try!(find_root_manifest_for_wd(options.flag_manifest_path,
                                               config.cwd()));
index e40d193c2419cfc525cda2df6ea4d1994b9cf981..fa8d792c2c195056418fb5a48baba5531721ac65 100644 (file)
@@ -4,8 +4,8 @@ use cargo::util::{CliResult, Config};
 #[derive(RustcDecodable)]
 pub struct Options {
     flag_host: Option<String>,
-    flag_verbose: bool,
-    flag_quiet: bool,
+    flag_verbose: Option<bool>,
+    flag_quiet: Option<bool>,
     flag_color: Option<String>,
     arg_query: String
 }
@@ -26,8 +26,9 @@ Options:
 ";
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
-    try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
-    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
+    try!(config.configure_shell(options.flag_verbose,
+                                options.flag_quiet,
+                                &options.flag_color));
     let Options {
         flag_host: host,
         arg_query: query,
index 08b13df7686121999b475298294e031664280ce1..c92a3c6c5cd58e8912be8e377013bbff04b3f294 100644 (file)
@@ -17,8 +17,8 @@ pub struct Options {
     flag_example: Vec<String>,
     flag_test: Vec<String>,
     flag_bench: Vec<String>,
-    flag_verbose: bool,
-    flag_quiet: bool,
+    flag_verbose: Option<bool>,
+    flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_release: bool,
     flag_no_fail_fast: bool,
@@ -74,9 +74,10 @@ by passing `--nocapture` to the test binaries:
 ";
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
+    try!(config.configure_shell(options.flag_verbose,
+                                options.flag_quiet,
+                                &options.flag_color));
     let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd()));
-    try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
-    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
 
     let ops = ops::TestOptions {
         no_run: options.flag_no_run,
index 5b4b345dd0ca4208b629e5c38260ac0d8d14f33f..ace6a25007e89480f1770d1159deab95ccb0c6cb 100644 (file)
@@ -5,8 +5,8 @@ use cargo::util::{CliResult, Config};
 pub struct Options {
     flag_bin: Vec<String>,
     flag_root: Option<String>,
-    flag_verbose: bool,
-    flag_quiet: bool,
+    flag_verbose: Option<bool>,
+    flag_quiet: Option<bool>,
     flag_color: Option<String>,
 
     arg_spec: String,
@@ -34,8 +34,9 @@ only uninstall particular binaries.
 ";
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
-    try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
-    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
+    try!(config.configure_shell(options.flag_verbose,
+                                options.flag_quiet,
+                                &options.flag_color));
 
     let root = options.flag_root.as_ref().map(|s| &s[..]);
     try!(ops::uninstall(root, &options.arg_spec, &options.flag_bin, config));
index 1a718125aafd4b5f4ae21cb21a21fe20db6a4885..77e4c470cc4e0d88237e426ed7904e5120056b2b 100644 (file)
@@ -10,8 +10,8 @@ pub struct Options {
     flag_aggressive: bool,
     flag_precise: Option<String>,
     flag_manifest_path: Option<String>,
-    flag_verbose: bool,
-    flag_quiet: bool,
+    flag_verbose: Option<bool>,
+    flag_quiet: Option<bool>,
     flag_color: Option<String>,
 }
 
@@ -54,8 +54,9 @@ For more information about package id specifications, see `cargo help pkgid`.
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
     debug!("executing; cmd=cargo-update; args={:?}", env::args().collect::<Vec<_>>());
-    try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
-    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
+    try!(config.configure_shell(options.flag_verbose,
+                                options.flag_quiet,
+                                &options.flag_color));
     let root = try!(find_root_manifest_for_wd(options.flag_manifest_path, config.cwd()));
 
     let update_opts = ops::UpdateOptions {
index 721b6eb7de594987f5519f6670d6f6d3fea8c045..7079a4a6e97afb7ce61b40e77206d3dccba1f0c1 100644 (file)
@@ -13,8 +13,8 @@ pub type Error = HashMap<String, String>;
 #[derive(RustcDecodable)]
 pub struct Flags {
     flag_manifest_path: Option<String>,
-    flag_verbose: bool,
-    flag_quiet: bool,
+    flag_verbose: Option<bool>,
+    flag_quiet: Option<bool>,
     flag_color: Option<String>,
 }
 
@@ -34,8 +34,9 @@ Options:
 ";
 
 pub fn execute(args: Flags, config: &Config) -> CliResult<Option<Error>> {
-    try!(config.shell().set_verbosity(args.flag_verbose, args.flag_quiet));
-    try!(config.shell().set_color_config(args.flag_color.as_ref().map(|s| &s[..])));
+    try!(config.configure_shell(args.flag_verbose,
+                                args.flag_quiet,
+                                &args.flag_color));
 
     let mut contents = String::new();
     let filename = args.flag_manifest_path.unwrap_or("Cargo.toml".into());
index feb2c73ccb2900b72c20265bdc4e055a169e8666..60718c7645d6fe555181774b63d08d58e27dac37 100644 (file)
@@ -7,8 +7,8 @@ pub struct Options {
     flag_token: Option<String>,
     flag_vers: Option<String>,
     flag_index: Option<String>,
-    flag_verbose: bool,
-    flag_quiet: bool,
+    flag_verbose: Option<bool>,
+    flag_quiet: Option<bool>,
     flag_color: Option<String>,
     flag_undo: bool,
 }
@@ -39,8 +39,9 @@ crates to be locked to any yanked version.
 ";
 
 pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
-    try!(config.shell().set_verbosity(options.flag_verbose, options.flag_quiet));
-    try!(config.shell().set_color_config(options.flag_color.as_ref().map(|s| &s[..])));
+    try!(config.configure_shell(options.flag_verbose,
+                                options.flag_quiet,
+                                &options.flag_color));
     try!(ops::yank(config,
                    options.arg_crate,
                    options.flag_vers,
index 00df39b703c05b27287c7db283a5000e9f651e92..4df18656db4f705f6f4aeed392effe2be504aa3e 100644 (file)
@@ -184,6 +184,22 @@ impl Config {
         }
     }
 
+    pub fn get_bool(&self, key: &str) -> CargoResult<Option<Value<bool>>> {
+        if let Some(v) = try!(self.get_env(key)) {
+            return Ok(Some(v))
+        }
+        match try!(self.get(key)) {
+            Some(CV::Boolean(b, path)) => {
+                Ok(Some(Value {
+                    val: b,
+                    definition: Definition::Path(path),
+                }))
+            }
+            Some(val) => self.expected("bool", key, val),
+            None => Ok(None),
+        }
+    }
+
     pub fn get_path(&self, key: &str) -> CargoResult<Option<Value<PathBuf>>> {
         if let Some(val) = try!(self.get_string(&key)) {
             let is_path = val.val.contains("/") ||
@@ -253,6 +269,22 @@ impl Config {
         })
     }
 
+    pub fn configure_shell(&self,
+                           verbose: Option<bool>,
+                           quiet: Option<bool>,
+                           color: &Option<String>) -> CargoResult<()> {
+        let cfg_verbose = try!(self.get_bool("term.verbose")).map(|v| v.val);
+        let cfg_color = try!(self.get_string("term.color")).map(|v| v.val);
+        let verbose = verbose.or(cfg_verbose).unwrap_or(false);
+        let quiet = quiet.unwrap_or(false);
+        let color = color.as_ref().or(cfg_color.as_ref());
+
+        try!(self.shell().set_verbosity(verbose, quiet));
+        try!(self.shell().set_color_config(color.map(|s| &s[..])));
+
+        Ok(())
+    }
+
     fn load_values(&self) -> CargoResult<()> {
         let mut cfg = CV::Table(HashMap::new(), PathBuf::from("."));
 
index d69d6b3002ac03f3d164af77d7d3d1ce5aeb697c..bb213b25ee8ab653cdd3cae67f5269eba6f4a1cc 100644 (file)
@@ -311,6 +311,7 @@ from_error! {
     ffi::NulError,
     term::Error,
     num::ParseIntError,
+    str::ParseBoolError,
 }
 
 impl From<string::ParseError> for Box<CargoError> {
@@ -338,6 +339,7 @@ impl CargoError for url::ParseError {}
 impl CargoError for ffi::NulError {}
 impl CargoError for term::Error {}
 impl CargoError for num::ParseIntError {}
+impl CargoError for str::ParseBoolError {}
 
 // =============================================================================
 // Construction helpers
index 3d66f8aebecdd790e3aaea34f883055b9d8c0ada..8b8bb509089b1f39454d7469656cea15cf5f4384 100644 (file)
@@ -84,6 +84,10 @@ rustc = "rustc"        # the rust compiler tool
 rustdoc = "rustdoc"    # the doc generator tool
 target = "triple"      # build for the target triple
 target-dir = "target"  # path of where to place all generated artifacts
+
+[term]
+verbose = false        # whether cargo provides verbose output
+color = 'auto'         # whether cargo colorizes output
 ```
 
 # Environment Variables