Skip to content

Commit 5d4a62d

Browse files
zaniebotzanieb
andauthored
Preserve workspace metadata output in quiet mode (#20991)
`uv workspace metadata --quiet` currently suppresses the JSON response along with diagnostic output, making the command unusable for callers that want machine-readable metadata without progress messages. Treat the metadata response as important stdout so a single `--quiet` preserves it, while repeated `--quiet` continues to suppress all output. Co-authored-by: Zanie Blue <[email protected]>
1 parent 1979349 commit 5d4a62d

2 files changed

Lines changed: 41 additions & 3 deletions

File tree

‎crates/uv/src/commands/workspace/metadata.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ fn metadata_for_target(target: InstallTarget<'_>) -> Result<Metadata> {
272272
}
273273

274274
fn print_metadata(export: &Metadata, printer: Printer) -> Result<ExitStatus> {
275-
if printer.stdout() == Stdout::Enabled {
275+
if printer.stdout_important() == Stdout::Enabled {
276276
let mut stdout = BufWriter::new(anstream::stdout().lock());
277277
export.write_json(&mut stdout)?;
278278
writeln!(stdout)?;

‎crates/uv/tests/workspace/workspace_metadata.rs‎

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,47 @@ fn workspace_metadata_quiet() {
136136

137137
let workspace = context.temp_dir.child("foo");
138138

139-
uv_snapshot!(context.filters(), context.workspace_metadata().current_dir(&workspace).arg("--quiet"), @r"
139+
uv_snapshot!(context.filters(), context.workspace_metadata().current_dir(&workspace).arg("--quiet"), @r#"
140140
exit_code: 0 (success)
141-
");
141+
----- stdout -----
142+
{
143+
"schema": {
144+
"version": "preview"
145+
},
146+
"workspace_root": "[TEMP_DIR]/foo",
147+
"workspace": {
148+
"path": "[TEMP_DIR]/foo",
149+
"id": "workspace+[TEMP_DIR]/foo"
150+
},
151+
"requires_python": ">=3.12",
152+
"conflicts": {
153+
"sets": []
154+
},
155+
"members": [
156+
{
157+
"name": "foo",
158+
"path": "[TEMP_DIR]/foo",
159+
"id": "foo==0.1.0@editable+[TEMP_DIR]/foo/"
160+
}
161+
],
162+
"resolution": {
163+
"foo==0.1.0@editable+[TEMP_DIR]/foo/": {
164+
"name": "foo",
165+
"version": "0.1.0",
166+
"source": {
167+
"editable": "[TEMP_DIR]/foo/"
168+
},
169+
"kind": "package",
170+
"dependencies": []
171+
},
172+
"workspace+[TEMP_DIR]/foo": {
173+
"kind": "workspace",
174+
"path": "[TEMP_DIR]/foo",
175+
"dependencies": []
176+
}
177+
}
178+
}
179+
"#);
142180
}
143181

144182
#[test]

0 commit comments

Comments
 (0)