Skip to content

Commit

Permalink
Auto merge of #2397 - alexcrichton:config-verbose, r=brson
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Feb 26, 2016
2 parents 4a8a38c + be48d5b commit 3efd44b
Show file tree
Hide file tree
Showing 29 changed files with 168 additions and 104 deletions.
9 changes: 5 additions & 4 deletions src/bin/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 5 additions & 4 deletions src/bin/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()));

Expand Down
9 changes: 5 additions & 4 deletions src/bin/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down Expand Up @@ -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();
Expand Down
9 changes: 5 additions & 4 deletions src/bin/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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 {
Expand Down
9 changes: 5 additions & 4 deletions src/bin/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
}
Expand Down Expand Up @@ -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()));

Expand Down
9 changes: 5 additions & 4 deletions src/bin/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
}

Expand Down Expand Up @@ -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)
Expand Down
9 changes: 5 additions & 4 deletions src/bin/generate_lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
}

Expand All @@ -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));
Expand Down
9 changes: 5 additions & 4 deletions src/bin/git_checkout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
}

Expand All @@ -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| {
Expand Down
9 changes: 5 additions & 4 deletions src/bin/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down Expand Up @@ -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;

Expand Down
9 changes: 5 additions & 4 deletions src/bin/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 5 additions & 4 deletions src/bin/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
}

Expand All @@ -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 => {
Expand Down
9 changes: 5 additions & 4 deletions src/bin/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "
Expand All @@ -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 {
Expand Down
9 changes: 5 additions & 4 deletions src/bin/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;

Expand Down
9 changes: 5 additions & 4 deletions src/bin/owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 5 additions & 4 deletions src/bin/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
9 changes: 5 additions & 4 deletions src/bin/pkgid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down Expand Up @@ -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[..]);
Expand Down
9 changes: 5 additions & 4 deletions src/bin/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand All @@ -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,
Expand Down
Loading

0 comments on commit 3efd44b

Please sign in to comment.