feat(cli): --json for members, du and public-link create/update

Scripts, the acceptance suite among them, can now read a link's id,
role, password flag and expiry, and a folder's size and item count,
instead of parsing the human-readable lines.
This commit is contained in:
nvrl committed 2026-10-27 00:42:44 +01:00
1 parent c1b72e455e
commit e4d2340bbf
2 files changed
+17 -6

No files matched your search

+14 -4
View File
@@ -1556,9 +1556,13 @@ fn cmd_versions(action: VersionCmd) -> Result<()> {
}
fn cmd_members(path: PathBuf) -> Result<()> {
match control_request(CtlRequest::ListShare {
let response = control_request(CtlRequest::ListShare {
path: path_arg(&path)?,
})? {
})?;
if emit_json(&response)? {
return Ok(());
}
match response {
CtlResponse::Share { entries, link } => {
if entries.is_empty() {
println!("No members or pending invitations.");
@@ -1625,6 +1629,7 @@ fn cmd_public_link(action: PublicLinkCmd) -> Result<()> {
password,
expires,
})? {
response if emit_json(&response)? => {}
CtlResponse::PublicLink { link } => {
println!("{}", link.url.as_deref().unwrap_or("(no url returned)"));
}
@@ -1646,6 +1651,7 @@ fn cmd_public_link(action: PublicLinkCmd) -> Result<()> {
password: link_change(password, no_password),
expires: link_change(expires, no_expiry),
})? {
response if emit_json(&response)? => {}
CtlResponse::PublicLink { link } => {
println!("{}", link.url.as_deref().unwrap_or("(no url returned)"));
}
@@ -3048,9 +3054,13 @@ fn cmd_copy(sources: Vec<PathBuf>, new_parent: PathBuf) -> Result<()> {
}
fn cmd_du(path: PathBuf) -> Result<()> {
match control_request(CtlRequest::FolderSize {
let response = control_request(CtlRequest::FolderSize {
path: path_arg(&path)?,
})? {
})?;
if emit_json(&response)? {
return Ok(());
}
match response {
CtlResponse::FolderSize { size, items } => {
let noun = if items == 1 { "item" } else { "items" };
println!(
+3 -2
View File
@@ -190,8 +190,9 @@ commands are for scripts and for cases where the mount is not available.
## Scripting with `--json`
The global `--json` flag makes query commands print JSON: `status`, `ls`, `pins`, `sync list`,
`devices list`, `locations`, `transfers`, `activity`, `trash` and `cache inspect`. Commands that change
something keep their human-readable output; check their exit code.
`devices list`, `locations`, `transfers`, `activity`, `trash`, `cache inspect`, `members` and `du`.
`public-link create` and `public-link update` print the link they made or changed. Other commands
that change something keep their human-readable output; check their exit code.
```bash
pdfs --json status | jq -r '.mount.mountpoint'