refactor(command): improve formula commitment and buffer management
Refactor command execution and buffer management. - `CommitFormula` now defaults to targeting `_Measure` . - `CommitFormula` no longer automatically clears the buffer; buffer clearing is now handled by keymap sequences. - Added `ClearBufferCmd` to the command registry. - Updated `AddFormulaCmd` to support optional target category. - Added `SetBuffer` effect to allow clearing buffers. Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/gemma-4-26B-A4B-it-GGUF:UD-Q5_K_XL)
This commit is contained in:
@ -200,11 +200,35 @@ effect_cmd!(
|
||||
effect_cmd!(
|
||||
AddFormulaCmd,
|
||||
"add-formula",
|
||||
|args: &[String]| require_args("add-formula", args, 2),
|
||||
|args: &[String]| {
|
||||
if args.is_empty() || args.len() > 2 {
|
||||
return Err(format!("add-formula requires 1-2 argument(s), got {}", args.len()));
|
||||
}
|
||||
Ok(())
|
||||
},
|
||||
|args: &Vec<String>, _ctx: &CmdContext| -> Vec<Box<dyn Effect>> {
|
||||
// 1 arg: formula text (target_category defaults to _Measure)
|
||||
// 2 args: target_category, formula text
|
||||
let (cat, raw) = if args.len() == 2 {
|
||||
(args[0].clone(), args[1].clone())
|
||||
} else {
|
||||
("_Measure".to_string(), args[0].clone())
|
||||
};
|
||||
vec![Box::new(effect::AddFormula {
|
||||
target_category: args[0].clone(),
|
||||
raw: args[1].clone(),
|
||||
target_category: cat,
|
||||
raw,
|
||||
})]
|
||||
}
|
||||
);
|
||||
|
||||
effect_cmd!(
|
||||
ClearBufferCmd,
|
||||
"clear-buffer",
|
||||
|args: &[String]| require_args("clear-buffer", args, 1),
|
||||
|args: &Vec<String>, _ctx: &CmdContext| -> Vec<Box<dyn Effect>> {
|
||||
vec![Box::new(effect::SetBuffer {
|
||||
name: args[0].clone(),
|
||||
value: String::new(),
|
||||
})]
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user