diff --git a/crates/pdfs-cli/src/main.rs b/crates/pdfs-cli/src/main.rs index 86a0069..75f6e3b 100644 --- a/crates/pdfs-cli/src/main.rs +++ b/crates/pdfs-cli/src/main.rs @@ -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, 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!( diff --git a/docs/CLI.md b/docs/CLI.md index 003b5da..96b6134 100644 --- a/docs/CLI.md +++ b/docs/CLI.md @@ -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'