Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/bin/cargo/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,9 +633,11 @@ See '<cyan,bold>cargo help</> <cyan><<command>></>' for more information on a sp
)
.arg(flag("quiet", "Do not print cargo log messages").short('q').global(true))
.arg(
opt("color", "Coloring: auto, always, never")
opt("color", "Coloring")
.value_name("WHEN")
.global(true),
.global(true)
.value_parser(["auto", "always", "never"])
.ignore_case(true),
)
.arg(
Arg::new("directory")
Expand Down
9 changes: 4 additions & 5 deletions src/bin/cargo/commands/locate_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ pub fn cli() -> Command {
.about("Print a JSON representation of a Cargo.toml file's location")
.arg(flag("workspace", "Locate Cargo.toml of the workspace root"))
.arg(
opt(
"message-format",
"Output representation [possible values: json, plain]",
)
.value_name("FMT"),
opt("message-format", "Output representation")
.value_name("FMT")
.value_parser(["json", "plain"])
.ignore_case(true),
)
.arg_silent_suggestion()
.arg_manifest_path()
Expand Down
14 changes: 13 additions & 1 deletion src/cargo/util/command_prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,19 @@ pub trait CommandExt: Sized {
}

fn arg_message_format(self) -> Self {
self._arg(multi_opt("message-format", "FMT", "Error format"))
self._arg(
multi_opt("message-format", "FMT", "Error format")
.value_parser([
"human",
"short",
"json",
"json-diagnostic-short",
"json-diagnostic-rendered-ansi",
"json-render-diagnostics",
])
.value_delimiter(',')
.ignore_case(true),
)
}

fn arg_build_plan(self) -> Self {
Expand Down
7 changes: 5 additions & 2 deletions tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4066,9 +4066,12 @@ fn wrong_message_format_option() {
.build();

p.cargo("build --message-format XML")
.with_status(101)
.with_status(1)
.with_stderr_data(str![[r#"
[ERROR] invalid message format specifier: `xml`
[ERROR] invalid value 'XML' for '--message-format <FMT>'
[possible values: human, short, json, json-diagnostic-short, json-diagnostic-rendered-ansi, json-render-diagnostics]

For more information, try '--help'.

"#]])
.run();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo/help/stdout.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
164 changes: 84 additions & 80 deletions tests/testsuite/cargo_add/help/stdout.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
104 changes: 54 additions & 50 deletions tests/testsuite/cargo_bench/help/stdout.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
112 changes: 58 additions & 54 deletions tests/testsuite/cargo_build/help/stdout.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
108 changes: 56 additions & 52 deletions tests/testsuite/cargo_check/help/stdout.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_clean/help/stdout.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_config/help/stdout.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading