use std::collections::HashMap;
use anyhow::Result;
use crate::{PromptStepType, replace_variables, apply_text_style};
pub fn handle_outro(
step_type: &PromptStepType,
context: &mut HashMap<String, String>,
last_input: &Option<String>
) -> Result<()> {
if let PromptStepType::Outro { text, input, output, style } = step_type {
let mut local_last_input = last_input.clone();
if let Some(input_key) = input {
if let Some(value) = context.get(input_key) {
local_last_input = Some(value.clone());
}
}
let processed_text = replace_variables(text, context, &local_last_input);
let styled_text = apply_text_style(&processed_text, style);
cliclack::outro(styled_text.clone())?;
println!("");
if let Some(output_key) = output {
context.insert(output_key.clone(), processed_text);
}
}
Ok(())
}