mirror of
https://github.com/actionbook/actionbook.git
synced 2026-09-19 03:28:06 +08:00
58545129de
- Delete packages/actionbook-rs/ (legacy 0.x CLI) - Delete old packages/cli/ (JS npm wrapper for 0.x) - Rename packages/cli-v2/ → packages/cli/ (git mv) - Merge npm wrapper files (bin/actionbook.js, scripts/postinstall.js) into new cli/ - Update package.json: name → @actionbookdev/cli, private → false, add npm distribution fields - Update sync-versions.js: point Cargo.toml/Cargo.lock sync at packages/cli/ - Update release.yml: build from packages/cli/ instead of packages/actionbook-rs/ - Update test.yml: paths and working-directory from cli-v2 → cli - Update CLAUDE.md, CONTRIBUTING.md, docs, issue templates - Delete stale changeset (fix-screenshot-timeout.md) - Keep 6 platform binary packages unchanged
73 lines
1.6 KiB
Rust
73 lines
1.6 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
use serde_json::Value;
|
|
|
|
/// Daemon → CLI response, classified by recovery strategy.
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(tag = "status")]
|
|
pub enum ActionResult {
|
|
Ok {
|
|
data: Value,
|
|
},
|
|
Retryable {
|
|
reason: String,
|
|
hint: String,
|
|
},
|
|
UserAction {
|
|
action: String,
|
|
hint: String,
|
|
},
|
|
Fatal {
|
|
code: String,
|
|
message: String,
|
|
hint: String,
|
|
#[serde(default)]
|
|
details: Option<Value>,
|
|
},
|
|
}
|
|
|
|
impl ActionResult {
|
|
pub fn ok(data: Value) -> Self {
|
|
ActionResult::Ok { data }
|
|
}
|
|
|
|
pub fn fatal(code: impl Into<String>, message: impl Into<String>) -> Self {
|
|
ActionResult::Fatal {
|
|
code: code.into(),
|
|
message: message.into(),
|
|
hint: String::new(),
|
|
details: None,
|
|
}
|
|
}
|
|
|
|
pub fn fatal_with_hint(
|
|
code: impl Into<String>,
|
|
message: impl Into<String>,
|
|
hint: impl Into<String>,
|
|
) -> Self {
|
|
ActionResult::Fatal {
|
|
code: code.into(),
|
|
message: message.into(),
|
|
hint: hint.into(),
|
|
details: None,
|
|
}
|
|
}
|
|
|
|
pub fn fatal_with_details(
|
|
code: impl Into<String>,
|
|
message: impl Into<String>,
|
|
hint: impl Into<String>,
|
|
details: Value,
|
|
) -> Self {
|
|
ActionResult::Fatal {
|
|
code: code.into(),
|
|
message: message.into(),
|
|
hint: hint.into(),
|
|
details: Some(details),
|
|
}
|
|
}
|
|
|
|
pub fn is_ok(&self) -> bool {
|
|
matches!(self, ActionResult::Ok { .. })
|
|
}
|
|
}
|