Add --message-format for install

Signed-off-by: hi-rustin <rustin.liu@gmail.com>
This commit is contained in:
hi-rustin 2021-11-21 12:16:50 +08:00
parent 7a947ae523
commit 6351472a80
2 changed files with 78 additions and 0 deletions

View File

@ -71,6 +71,7 @@ pub fn cli() -> App {
.requires("crate")
.conflicts_with_all(&["git", "path", "index"]),
)
.arg_message_format()
.after_help("Run `cargo help install` for more detailed information.\n")
}

View File

@ -54,6 +54,83 @@ fn simple() {
assert_has_not_installed_exe(cargo_home(), "foo");
}
#[cargo_test]
fn simple_with_message_format() {
pkg("foo", "0.0.1");
cargo_process("install foo --message-format=json")
.with_stderr(
"\
[UPDATING] `[..]` index
[DOWNLOADING] crates ...
[DOWNLOADED] foo v0.0.1 (registry [..])
[INSTALLING] foo v0.0.1
[COMPILING] foo v0.0.1
[FINISHED] release [optimized] target(s) in [..]
[INSTALLING] [CWD]/home/.cargo/bin/foo[EXE]
[INSTALLED] package `foo v0.0.1` (executable `foo[EXE]`)
[WARNING] be sure to add `[..]` to your PATH to be able to run the installed binaries
",
)
.with_json(
r#"
{
"reason": "compiler-artifact",
"package_id": "foo 0.0.1 ([..])",
"manifest_path": "[..]",
"target": {
"kind": [
"lib"
],
"crate_types": [
"lib"
],
"name": "foo",
"src_path": "[..]/foo-0.0.1/src/lib.rs",
"edition": "2015",
"doc": true,
"doctest": true,
"test": true
},
"profile": "{...}",
"features": [],
"filenames": "{...}",
"executable": null,
"fresh": false
}
{
"reason": "compiler-artifact",
"package_id": "foo 0.0.1 ([..])",
"manifest_path": "[..]",
"target": {
"kind": [
"bin"
],
"crate_types": [
"bin"
],
"name": "foo",
"src_path": "[..]/foo-0.0.1/src/main.rs",
"edition": "2015",
"doc": true,
"doctest": false,
"test": true
},
"profile": "{...}",
"features": [],
"filenames": "{...}",
"executable": "[..]",
"fresh": false
}
{"reason":"build-finished","success":true}
"#,
)
.run();
assert_has_installed_exe(cargo_home(), "foo");
}
#[cargo_test]
fn with_index() {
pkg("foo", "0.0.1");