use super::parse::act;
use super::{Context, args};
pub(super) use crate::boundary::codec::workflow::{CLEAR, WORKFLOW};
use crate::boundary::{Action, Gesture};
pub(super) fn read(verb: &str, tail: &str, ctx: &Context) -> Result<Gesture, String> {
let config = if verb == WORKFLOW {
Some(args::required(
tail,
verb,
"the lineage whose workflow to run",
)?)
} else {
args::none(tail, verb)?;
None
};
Ok(act(Action::Workflow {
workspace: args::workspace(ctx, verb)?,
agent: args::agent(ctx, verb)?,
config,
}))
}
pub(super) fn spell(config: Option<&str>) -> String {
match config {
Some(name) => format!("/{WORKFLOW} {name}"),
None => format!("/{CLEAR}"),
}
}