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>,
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,
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,
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()));
#[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>,
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();
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,
}
";
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 {
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>,
}
";
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()));
#[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>,
}
";
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)
#[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>,
}
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));
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>,
}
";
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| {
#[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>,
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;
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,
";
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,
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>,
}
";
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 => {
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 = "
";
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 {
#[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,
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;
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,
}
";
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,
#[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,
";
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,
#[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>,
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[..]);
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,
}
";
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,
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>,
";
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()));
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,
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()));
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,
";
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()));
#[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
}
";
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,
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,
";
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,
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,
";
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));
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>,
}
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 {
#[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>,
}
";
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());
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,
}
";
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,
}
}
+ 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("/") ||
})
}
+ 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("."));
ffi::NulError,
term::Error,
num::ParseIntError,
+ str::ParseBoolError,
}
impl From<string::ParseError> for Box<CargoError> {
impl CargoError for ffi::NulError {}
impl CargoError for term::Error {}
impl CargoError for num::ParseIntError {}
+impl CargoError for str::ParseBoolError {}
// =============================================================================
// Construction helpers
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