feat: phase 2 — playbooks (am history --save + am playbook, rejeu pas à pas) (closes #51)
This commit is contained in:
+26
-5
@@ -115,6 +115,7 @@ const COMMAND_DESCRIPTIONS: &[(&str, &str)] = &[
|
||||
("monitor", "real-time TUI of managed processes (cpu/rss/uptime)"),
|
||||
("sync", "push the state (journal, sessions, config) into a git repo"),
|
||||
("migrate", "export/import a machine transfer bundle (config + state)"),
|
||||
("playbook", "replay a saved history sequence step by step (am history --save)"),
|
||||
("shell", "show or switch the system shell"),
|
||||
("theme", "show or switch the color theme"),
|
||||
("tip", "cheat sheet of the most useful commands"),
|
||||
@@ -229,7 +230,7 @@ impl AmCompleter {
|
||||
"self-update", "self-uninstall", "export", "import", "shell", "theme",
|
||||
"tip", "dashboard", "favorite", "unfavorite", "note", "tag", "untag", "tags",
|
||||
"profile", "man", "models", "catalog", "suggest", "audit",
|
||||
"service", "schedule", "monitor", "sync", "migrate",
|
||||
"service", "schedule", "monitor", "sync", "migrate", "playbook",
|
||||
"ls", "dir", "cd", "ps", "where", "get", "help", "version", "exit",
|
||||
],
|
||||
config_sub: vec!["show", "path", "edit", "validate", "add"],
|
||||
@@ -779,7 +780,7 @@ pub fn banner_box(
|
||||
" models models · models --prune · catalog · suggest · audit".to_string(),
|
||||
));
|
||||
rows.push(inner(
|
||||
" automate service install · schedule add · doctor --watch · monitor · sync · migrate".to_string(),
|
||||
" automate service install · schedule add · doctor --watch · monitor · sync · migrate · playbook".to_string(),
|
||||
));
|
||||
rows.push(inner(
|
||||
" system self-update · self-uninstall · export · import".to_string(),
|
||||
@@ -1597,10 +1598,24 @@ fn handle_line(
|
||||
kind: opt_value("--kind"),
|
||||
cwd: opt_value("--cwd"),
|
||||
search: opt_value("--search"),
|
||||
failed: flag("--failed"),
|
||||
session: opt_value("--session"),
|
||||
failed: flag("--failed"), session: opt_value("--session"),
|
||||
limit: opt_value("--limit").and_then(|v| v.parse().ok()).unwrap_or(100),
|
||||
rerun: opt_value("--rerun").and_then(|v| v.parse().ok()),
|
||||
range: rest.first().cloned(),
|
||||
save: opt_value("--save").map(std::path::PathBuf::from),
|
||||
},
|
||||
"playbook" => {
|
||||
if rest.is_empty() {
|
||||
app.log.error("usage: playbook <file> — ex: playbook deploy.yaml");
|
||||
return Ok(false);
|
||||
}
|
||||
Command::Playbook {
|
||||
path: std::path::PathBuf::from(rest[0].clone()),
|
||||
var: rest
|
||||
.iter()
|
||||
.filter_map(|t| t.strip_prefix("--var=").map(|v| v.to_string()))
|
||||
.collect(),
|
||||
}
|
||||
},
|
||||
"init" => Command::Init {
|
||||
force: flag("--force"),
|
||||
@@ -1794,7 +1809,7 @@ fn completion_pool_mutating(first: &str) -> bool {
|
||||
|
||||
/// Whether a word is one of the am commands (everything else is executed by
|
||||
/// the system shell).
|
||||
fn is_am_command(word: &str) -> bool {
|
||||
pub fn is_am_command(word: &str) -> bool {
|
||||
matches!(
|
||||
word,
|
||||
"list"
|
||||
@@ -1843,6 +1858,12 @@ fn is_am_command(word: &str) -> bool {
|
||||
| "catalog"
|
||||
| "suggest"
|
||||
| "audit"
|
||||
| "service"
|
||||
| "schedule"
|
||||
| "monitor"
|
||||
| "sync"
|
||||
| "migrate"
|
||||
| "playbook"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user