use crate::boundary::Query;
use crate::boundary::config::Read;
fn spell_config(read: &Read) -> String {
match read {
Read::File { file } => format!(
"/config {}",
crate::boundary::line::config::target_words(file)
),
Read::Marks { .. } => "/marks".to_owned(),
Read::Providers { .. } => "/providers".to_owned(),
Read::Roles { .. } => "/roles".to_owned(),
Read::Lineages { .. } => "/lineages".to_owned(),
Read::Models { provider, .. } => format!("/models {provider}"),
}
}
pub(super) fn spell_query(query: &Query) -> String {
match query {
Query::Workspaces => "/workspaces".to_owned(),
Query::Conversations { .. } => "/conversations".to_owned(),
Query::Balls => "/balls".to_owned(),
Query::WorkspaceBalls { .. } => "/workspace-balls".to_owned(),
Query::WorkDiff { file, .. } => match file {
Some(file) => match &file.handle {
Some(handle) => format!("/work-diff {} {handle} {}", file.ball, file.path),
None => format!("/work-diff {} {}", file.ball, file.path),
},
None => "/work-diff".to_owned(),
},
Query::Science { .. } => "/science".to_owned(),
Query::Transcript { .. } => "/transcript".to_owned(),
Query::Follow { .. } => "/follow".to_owned(),
Query::Steps { .. } => "/steps".to_owned(),
Query::Step { seq, .. } => format!("/step {seq}"),
Query::Files { path, at, .. } => {
let pinned = at
.as_ref()
.map(|c| format!(" --at {c}"))
.unwrap_or_default();
match path {
Some(path) => format!("/files {path}{pinned}"),
None => format!("/files{pinned}"),
}
}
Query::Governing { at, .. } => match at {
Some(commit) => format!("/governing --at {commit}"),
None => "/governing".to_owned(),
},
Query::Rail { .. } => "/rail".to_owned(),
Query::Agent { .. } => "/agent".to_owned(),
Query::Inbox { .. } => "/inbox".to_owned(),
Query::Board => "/board".to_owned(),
Query::Attention => "/attention".to_owned(),
Query::Ops { max } => format!("/ops {max}"),
Query::Search { text } => format!("/search {text}"),
Query::Help { verb } => match verb {
Some(verb) => format!("/help {verb}"),
None => "/help".to_owned(),
},
Query::Config(read) => spell_config(read),
Query::Clients { .. } => "/clients".to_owned(),
Query::Doctor { .. } => "/doctor".to_owned(),
Query::LoginTail { provider, .. } => {
format!("/{} {provider}", crate::boundary::line::queries::LOGIN_TAIL)
}
Query::Invocations => "/invocations".to_owned(),
Query::Capture { invocation } => format!("/capture {invocation}"),
}
}