use super::ShellState;
use crate::AppModel;
use crate::cli_outbound::Cli;
use crate::start::StartInputs;
use std::path::Path;
pub(super) fn fire_start(
model: &mut AppModel,
state: &mut ShellState,
lernie: &Cli,
bl: &Cli,
text: &str,
) -> bool {
let dir = state.actions.path_dir.trim().to_owned();
let inputs = if dir.is_empty() {
model.start_bare_inputs()
} else {
model.start_path_inputs(Path::new(&dir))
};
fire_inputs(model, state, lernie, bl, inputs, text)
}
pub(super) fn fire_bare(
model: &mut AppModel,
state: &mut ShellState,
lernie: &Cli,
bl: &Cli,
text: &str,
) -> bool {
let inputs = model.start_bare_inputs();
fire_inputs(model, state, lernie, bl, inputs, text)
}
fn fire_inputs(
model: &mut AppModel,
state: &mut ShellState,
lernie: &Cli,
bl: &Cli,
inputs: StartInputs,
text: &str,
) -> bool {
let launched = match model.prepare_start(
lernie,
bl,
&inputs.workspace,
&inputs.payload,
&super::now_ts(),
) {
Ok(p) => {
let fired = model
.fire_prompt(
lernie,
bl,
&p,
text,
state.start.mint_seed,
&super::now_ts(),
)
.is_ok();
if fired {
state.start.spend_mint();
}
fired
}
Err(_) => false,
};
model.after_lernie_verb();
launched
}