Skip to content

Commit 51a9146

Browse files
authored
add --message-format to cargo common args (#648)
Add `--message-format` option to `bevy` subcommands. Fix: #647
1 parent 2749ab4 commit 51a9146

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/external_cli/cargo/mod.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{env, ffi::OsString};
22

3-
use clap::{ArgAction, Args};
3+
use clap::{ArgAction, Args, ValueEnum};
44

55
use super::arg_builder::ArgBuilder;
66

@@ -146,6 +146,16 @@ impl CargoManifestArgs {
146146
}
147147
}
148148

149+
#[derive(ValueEnum, Copy, Clone, Debug, PartialEq, Eq)]
150+
pub enum MessageFormat {
151+
Human,
152+
Short,
153+
Json,
154+
JsonDiagnosticShort,
155+
JsonDiagnosticRenderedAnsi,
156+
JsonRenderDiagnostics,
157+
}
158+
149159
/// Common options available for `cargo` commands.
150160
#[derive(Debug, Args, Clone)]
151161
pub struct CargoCommonArgs {
@@ -156,6 +166,9 @@ pub struct CargoCommonArgs {
156166
/// This flag may be specified multiple times.
157167
#[clap(long = "config", value_name = "KEY=VALUE|PATH")]
158168
pub config: Vec<String>,
169+
/// Error format
170+
#[clap(long = "message-format", value_name = "FMT")]
171+
pub message_format: Option<MessageFormat>,
159172
/// custom flags to pass to all compiler invocations
160173
#[arg(long = "rustflags", allow_hyphen_values = true)]
161174
pub rustflags: Option<String>,
@@ -168,6 +181,13 @@ impl CargoCommonArgs {
168181
pub(crate) fn args_builder(&self) -> ArgBuilder {
169182
ArgBuilder::new()
170183
.add_values_separately("--config", self.config.iter())
184+
.add_opt_value(
185+
"--message-format",
186+
&self.message_format.and_then(|fmt| {
187+
fmt.to_possible_value()
188+
.map(|value| value.get_name().to_owned())
189+
}),
190+
)
171191
.add_values_separately("-Z", self.unstable_flags.iter())
172192
}
173193
}

0 commit comments

Comments
 (0)