Add local CAS file roots
This commit is contained in:
parent
64e17ff957
commit
e1f36ffafb
12 changed files with 581 additions and 13 deletions
|
|
@ -216,6 +216,17 @@ pub enum CasCommand {
|
|||
dry_run: bool,
|
||||
},
|
||||
List,
|
||||
Root {
|
||||
#[command(subcommand)]
|
||||
command: CasRootCommand,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum CasRootCommand {
|
||||
Add { name: String, path: PathBuf },
|
||||
List,
|
||||
Scan { name: String },
|
||||
}
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
|
|
@ -464,6 +475,11 @@ fn request_for_command(command: Command) -> Result<ControlRequest> {
|
|||
CasCommand::Unpin { hash } => ControlRequest::CasUnpin { hash: hash.into() },
|
||||
CasCommand::Cleanup { dry_run } => ControlRequest::CasCleanup { dry_run },
|
||||
CasCommand::List => ControlRequest::CasList,
|
||||
CasCommand::Root { command } => match command {
|
||||
CasRootCommand::Add { name, path } => ControlRequest::CasRootAdd { name, path },
|
||||
CasRootCommand::List => ControlRequest::CasRootList,
|
||||
CasRootCommand::Scan { name } => ControlRequest::CasRootScan { name },
|
||||
},
|
||||
},
|
||||
Command::Kv { command } => match command {
|
||||
KvCommand::Create { name } => ControlRequest::KvCreate { name },
|
||||
|
|
@ -696,6 +712,38 @@ fn print_response(response: ControlResponse, json: bool) -> Result<()> {
|
|||
println!("{}\t{} bytes\t{}", blob.hash, blob.size_bytes, pin);
|
||||
}
|
||||
}
|
||||
ControlResponse::CasRootAdded { root } => {
|
||||
println!("added file root: {}", root.name);
|
||||
println!("id: {}", root.id);
|
||||
println!("resource: {}", root.resource);
|
||||
println!("path: {}", root.path);
|
||||
}
|
||||
ControlResponse::CasRootList { roots } => {
|
||||
if roots.is_empty() {
|
||||
println!("no file roots");
|
||||
} else {
|
||||
for root in roots {
|
||||
println!(
|
||||
"{}\t{}\t{}",
|
||||
root.name,
|
||||
root.path,
|
||||
root.latest_tree
|
||||
.map(|hash| hash.to_string())
|
||||
.unwrap_or_else(|| "unscanned".to_owned())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
ControlResponse::CasRootScanned { scan } => {
|
||||
println!("file root: {}", scan.root.name);
|
||||
println!("tree: {}", scan.tree.hash);
|
||||
println!("tree_bytes: {}", scan.tree.size_bytes);
|
||||
println!("changes: {}", scan.changes.len());
|
||||
for change in scan.changes {
|
||||
println!("{change:?}");
|
||||
}
|
||||
println!("note: {}", scan.note);
|
||||
}
|
||||
ControlResponse::KeychainStatus(status) => {
|
||||
println!("initialized: {}", status.initialized);
|
||||
println!("admin_keys: {}", status.admin_keys);
|
||||
|
|
|
|||
Loading…
Reference in a new issue