Support accessing repositories using DOI strings with optional subpaths
across ls, download, metadata, and file-metadata commands.
- Implement GET v3/doi/{id}/ API model and client calls
- Parse and resolve DOI paths into respective folder and files
- Extract common folder and file resolution logic to shared helpers
- Update README with example DOI-based shell commands
20 lines
713 B
Rust
20 lines
713 B
Rust
use crate::cache::create_readonly_conn;
|
|
use crate::commands::shared::resolve_remote_folder;
|
|
|
|
pub async fn metadata(remote_path: &str, password: Option<&str>) -> Result<(), anyhow::Error> {
|
|
let remote = remote_path
|
|
.splitn(2, ':')
|
|
.next()
|
|
.ok_or_else(|| anyhow::anyhow!("Invalid remote path"))?;
|
|
let (conn, cache) = create_readonly_conn(remote).await?;
|
|
let (folder, _) =
|
|
resolve_remote_folder(&conn, cache.as_ref(), None, remote_path, password).await?;
|
|
|
|
let resp = conn
|
|
.get(&format!("v3/folders/{}/metadata/", folder.id))
|
|
.await?;
|
|
let json: serde_json::Value = resp.json().await?;
|
|
println!("{}", serde_json::to_string(&json)?);
|
|
Ok(())
|
|
}
|