implemented arguments show_stack_on_push/pop
added setting `stack_hide_numbers`
This commit is contained in:
@@ -71,10 +71,6 @@ pub struct StackArgs {
|
||||
#[arg(short = 'n', long)]
|
||||
pub hide_numbers: Option<bool>,
|
||||
|
||||
/// show n entries
|
||||
#[arg(short, long = "lines")]
|
||||
pub lines: Option<u32>,
|
||||
|
||||
/// stack subcommand
|
||||
#[command(subcommand)]
|
||||
pub stack_action: Option<StackAction>,
|
||||
|
||||
@@ -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,
|
||||
|
||||
+10
-4
@@ -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(())
|
||||
}
|
||||
|
||||
+3
-1
@@ -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));
|
||||
|
||||
@@ -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..
|
||||
|
||||
Reference in New Issue
Block a user