implemented arguments show_stack_on_push/pop

added setting `stack_hide_numbers`
This commit is contained in:
2025-02-06 23:27:39 +01:00
parent c846a16c8f
commit c45373e1ab
5 changed files with 20 additions and 11 deletions
+10 -4
View File
@@ -85,7 +85,9 @@ fn main() -> Result<()> {
}
fn handle_push(args: &PushArgs, config: &Config, stack: &mut Stack, output: &mut Output) -> Result<()> {
// paths arguments starting with `=` are interpreted as stack entry number
const PREFIX: char = '=';
let mut path_string = match args.path.clone() {
Some(value) => value,
None => {
@@ -110,6 +112,11 @@ fn handle_push(args: &PushArgs, config: &Config, stack: &mut Stack, output: &mut
Err(_) => return Err(Error::other("-- failed to create PathBuf from argument")),
}
};
if let Some(true) = args.show_stack {
output.push_info(&stack.to_formatted_string(&config)?);
} else if config.general.show_stack_on_push {
output.push_info(&stack.to_formatted_string(&config)?);
}
push_path(&path, stack, config, output)?;
Ok(())
}
@@ -124,7 +131,9 @@ fn handle_pop(args: &PopArgs, config: &Config, stack: &mut Stack, output: &mut O
num = Some(*n);
}
let path = stack.pop_entry(num)?;
if config.general.show_stack_on_push {
if let Some(true) = args.show_stack {
output.push_info(&stack.to_formatted_string(config)?);
} else if config.general.show_stack_on_push {
output.push_info(&stack.to_formatted_string(config)?);
}
output.push_command(&format!("cd -- {}", match path.to_str() {
@@ -224,8 +233,5 @@ fn push_path(path: &Path, stack: &mut Stack, config: &Config, output: &mut Outpu
None => return Err(Error::other("-- failed to print provided path as string")),
}));
}
if config.general.show_stack_on_push {
output.push_info(&stack.to_formatted_string(&config)?);
}
Ok(())
}