diff --git a/src/cli.rs b/src/cli.rs index 1d24a07..be1fe8f 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -6,6 +6,7 @@ pub struct Args { all: Vec, subcommand: Option, target: Option, + message_format: Option } impl Args { @@ -21,6 +22,10 @@ impl Args { self.target.as_ref().map(|s| &**s) } + pub fn message_format(&self) -> Option<&str> { + self.message_format.as_ref().map(|s| &**s) + } + pub fn verbose(&self) -> bool { self.all .iter() @@ -37,6 +42,7 @@ pub fn args() -> Args { let mut sc = None; let mut target = None; + let mut message_format = None; { let mut args = all.iter(); while let Some(arg) = args.next() { @@ -48,6 +54,10 @@ pub fn args() -> Args { target = args.next().map(|s| s.to_owned()); } else if arg.starts_with("--target=") { target = arg.splitn(2, '=').nth(1).map(|s| s.to_owned()); + } else if arg == "--message-format" { + message_format = args.next().map(|s| s.to_owned()); + } else if arg.starts_with("--message-format=") { + message_format = arg.splitn(2, '=').nth(1).map(|s| s.to_owned()); } } } @@ -56,5 +66,6 @@ pub fn args() -> Args { all: all, subcommand: sc, target: target, + message_format: message_format } } diff --git a/src/main.rs b/src/main.rs index f377fcc..908336d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -187,6 +187,7 @@ fn run() -> Result { &src, &sysroot, verbose, + args.message_format() )?; return xargo::run( &args, diff --git a/src/sysroot.rs b/src/sysroot.rs index 4a934f4..8d9d230 100644 --- a/src/sysroot.rs +++ b/src/sysroot.rs @@ -38,6 +38,7 @@ fn build( sysroot: &Sysroot, hash: u64, verbose: bool, + message_format: Option<&str> ) -> Result<()> { const TOML: &'static str = r#" [package] @@ -145,6 +146,9 @@ version = "0.0.0" cmd.arg("--manifest-path"); cmd.arg(td.join("Cargo.toml")); cmd.args(&["--target", cmode.triple()]); + if let Some(format) = message_format { + cmd.args(&["--message-format", format]); + } if verbose { cmd.arg("-v"); @@ -229,6 +233,7 @@ pub fn update( src: &Src, sysroot: &Sysroot, verbose: bool, + message_format: Option<&str> ) -> Result<()> { let ctoml = cargo::toml(root)?; let xtoml = xargo::toml(root)?; @@ -248,6 +253,7 @@ pub fn update( sysroot, hash, verbose, + message_format, )?; }