diff --git a/src/arguments.rs b/src/arguments.rs index 33aa5f5..97a1593 100644 --- a/src/arguments.rs +++ b/src/arguments.rs @@ -71,10 +71,6 @@ pub struct StackArgs { #[arg(short = 'n', long)] pub hide_numbers: Option, - /// show n entries - #[arg(short, long = "lines")] - pub lines: Option, - /// stack subcommand #[command(subcommand)] pub stack_action: Option, diff --git a/src/config.rs b/src/config.rs index ec81fd7..fbbb296 100644 --- a/src/config.rs +++ b/src/config.rs @@ -43,6 +43,10 @@ pub struct FormatSettings { #[default_value(false)] pub show_home_as_tilde: bool, + /// (bool) hide numbers when displaying the stack + #[default_value(false)] + pub stack_hide_numbers: bool, + /// (string) separator between stack numbers and paths #[default_value("' - '")] pub stack_separator: String, diff --git a/src/main.rs b/src/main.rs index ee0bfd5..83027c7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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(()) } diff --git a/src/stack.rs b/src/stack.rs index bc2ec8a..7a53eb6 100644 --- a/src/stack.rs +++ b/src/stack.rs @@ -61,7 +61,9 @@ impl Stack { path = path.replace(&home, "~"); } path = path.replace('/', &format!("{}{}/{}{}", RESET_SEQ, config.styles.stack_punct_style, RESET_SEQ, config.styles.stack_path_style)); - if config.format.align_separators { + if config.format.stack_hide_numbers { + buffer.push_str(&format!("{}\n", path)); + } else if config.format.align_separators { buffer.push_str(&format!("{}{}{}{}\n", number, padding, separator, path)); } else { buffer.push_str(&format!("{}{}{}{}\n", number, separator, padding, path)); diff --git a/todo.md b/todo.md index 13e64f9..04f9793 100644 --- a/todo.md +++ b/todo.md @@ -6,10 +6,10 @@ - [x] config file - [x] implement procedural macro for config - [x] .. to parse config - - [ ] .. to write default config + - [x] .. to write default config - [x] .. ignore comments in config file - [x] parse config file - - [ ] apply config -- partially more done than before :) + - [x] apply config -- partially more done than before :) - [x] `show-bookmarks-on-book` - [x] setting for separator string when displaying stack/bookmarks - [x] color option for punctuation (mostly '/') @@ -20,3 +20,4 @@ - [x] change config file extension to `.toml` - [x] add bash completions - [x] option to show home directory as '~' +- [x] apply arguments or delete them..