feat: add cli execution previews
This commit is contained in:
1 parent
a326b92744
commit
633b39eb53
1 file changed
+35
-3
@@ -478,14 +478,46 @@ fn execution_stub(contract: &ExecutionContract) -> ExecutionStub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn execution_preview(_cli: &Cli, stub: &ExecutionStub) -> ExecutionPreview {
|
fn execution_preview(cli: &Cli, stub: &ExecutionStub) -> ExecutionPreview {
|
||||||
match stub {
|
match stub {
|
||||||
ExecutionStub::SummaryOnly { command } => ExecutionPreview::SummaryOnly {
|
ExecutionStub::SummaryOnly { command } => ExecutionPreview::SummaryOnly {
|
||||||
command: command.clone(),
|
command: command.clone(),
|
||||||
},
|
},
|
||||||
_ => ExecutionPreview::SummaryOnly {
|
ExecutionStub::HttpRequest {
|
||||||
command: "preview-unimplemented".to_owned(),
|
method,
|
||||||
|
path,
|
||||||
|
api_key_present,
|
||||||
|
body,
|
||||||
|
} => ExecutionPreview::HttpPreview {
|
||||||
|
method,
|
||||||
|
url: format!("{}{}", cli.server.trim_end_matches('/'), path),
|
||||||
|
api_key_present: *api_key_present,
|
||||||
|
body: body.clone(),
|
||||||
},
|
},
|
||||||
|
ExecutionStub::LocalAction {
|
||||||
|
action,
|
||||||
|
target,
|
||||||
|
detail,
|
||||||
|
} => ExecutionPreview::LocalPreview {
|
||||||
|
action,
|
||||||
|
target: target.clone(),
|
||||||
|
effect: preview_effect(action, detail.as_deref()),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn preview_effect(action: &str, detail: Option<&str>) -> String {
|
||||||
|
match (action, detail) {
|
||||||
|
("scan_models_dir", _) => "discover available model files".to_owned(),
|
||||||
|
("load_model", Some(detail)) => format!("load {}", detail),
|
||||||
|
("configure_auth", Some(detail)) => format!("set {}", detail),
|
||||||
|
("write_config", Some(detail)) => format!("persist {}", detail),
|
||||||
|
("tail_logs", Some(detail)) => detail
|
||||||
|
.strip_prefix("lines=")
|
||||||
|
.map(|lines| format!("tail last {} lines", lines))
|
||||||
|
.unwrap_or_else(|| format!("apply {}", detail)),
|
||||||
|
(_, Some(detail)) => format!("apply {}", detail),
|
||||||
|
(_, None) => format!("run {}", action),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user