fixed bookmarks completions and error messages
This commit is contained in:
+9
-2
@@ -158,8 +158,15 @@ impl Bookmarks {
|
||||
}
|
||||
|
||||
/// get bookmarknames as space separated values in one string (for shell completions)
|
||||
pub fn get_bookmarknames(&self) -> String {
|
||||
let names: Vec<String> = self.bookmarks.keys().cloned().collect();
|
||||
pub fn get_bookmark_names(&self) -> String {
|
||||
let mut copy = self.bookmarks.clone();
|
||||
|
||||
for (name, path) in copy.clone() {
|
||||
if !path.is_dir() {
|
||||
_ = copy.remove(&name);
|
||||
}
|
||||
}
|
||||
let names: Vec<String> = copy.keys().cloned().collect();
|
||||
names.join(" ")
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -163,7 +163,7 @@ fn handle_bookmark(args: &BookmarkArgs, config: &Config, bookmarks: &mut Bookmar
|
||||
BookmarkAction::list => list_bookmarks(config, bookmarks, output)?,
|
||||
BookmarkAction::add(args) => add_bookmarks(args, config, bookmarks, output)?,
|
||||
BookmarkAction::remove(args) => remove_bookmarks(args, config, bookmarks, output)?,
|
||||
BookmarkAction::completions => println!("echo '{}'", bookmarks.get_bookmarknames()),
|
||||
BookmarkAction::completions => println!("echo '{}'", bookmarks.get_bookmark_names()),
|
||||
};
|
||||
} else if args.name.is_some() { // handle `change to bookmark`
|
||||
let path = bookmarks.get_path_by_name(args.name.as_ref().unwrap())?;
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
#![allow(unused)]
|
||||
|
||||
use clap::builder::EnumValueParser;
|
||||
use config_parser::RESET_SEQ;
|
||||
use config_parser::apply_format;
|
||||
|
||||
use super::config::*;
|
||||
|
||||
@@ -81,11 +81,11 @@ impl Output {
|
||||
output.push(info);
|
||||
}
|
||||
if !warning.is_empty() {
|
||||
warning = format!("echo '{}' && {}", config.styles.warning_style, warning);
|
||||
warning = format!("echo '{}'", apply_format(&warning, &config.styles.error_style).unwrap());
|
||||
output.push(warning);
|
||||
}
|
||||
if !error.is_empty() {
|
||||
error = format!("echo '{}' && {}", config.styles.error_style, error);
|
||||
error = format!("echo '{}'", apply_format(&error, &config.styles.error_style).unwrap());
|
||||
output.push(error);
|
||||
}
|
||||
if !command.is_empty() {
|
||||
|
||||
Reference in New Issue
Block a user