Add local document JSON state commands

This commit is contained in:
Eric Wendland 2026-05-17 19:59:03 +02:00
commit e039a4f81f
11 changed files with 153 additions and 10 deletions

View file

@ -256,6 +256,8 @@ pub enum DbCommand {
pub enum DocumentCommand {
Create { name: String },
Status { name: String },
Set { name: String, state_json: String },
Get { name: String },
}
#[derive(Debug, Subcommand)]
@ -471,6 +473,10 @@ fn request_for_command(command: Command) -> Result<ControlRequest> {
Command::Document { command } => match command {
DocumentCommand::Create { name } => ControlRequest::DocumentCreate { name },
DocumentCommand::Status { name } => ControlRequest::DocumentStatus { name },
DocumentCommand::Set { name, state_json } => {
ControlRequest::DocumentSet { name, state_json }
}
DocumentCommand::Get { name } => ControlRequest::DocumentGet { name },
},
Command::Ssh { command } => match command {
SshCommand::Proxy { node } => ControlRequest::ModuleStub {
@ -904,6 +910,14 @@ fn print_response(response: ControlResponse, json: bool) -> Result<()> {
println!("sync_status: {}", document.sync_status);
println!("state_bytes: {}", document.state_bytes);
}
ControlResponse::DocumentSet { state } => {
println!("updated document: {}", state.document.name);
println!("state_bytes: {}", state.document.state_bytes);
println!("updated_at_ms: {}", state.updated_at.0);
}
ControlResponse::DocumentGet { state } => {
println!("{}", state.state_json);
}
ControlResponse::PubsubPublished { message } => {
println!("published: {}", message.topic);
println!("published_at_ms: {}", message.published_at.0);