added shell completions for push and bookmarks

This commit is contained in:
2025-01-19 22:52:24 +01:00
parent 64e12222bd
commit 5c7a8548d4
4 changed files with 31 additions and 4 deletions
+3
View File
@@ -103,6 +103,9 @@ pub enum BookmarkAction {
/// remove a bookmark by name `book remove <name>`
remove(BookmarkSubArgs),
/// get bookmarknames for shell completions
names(EmptyArgs),
}
#[derive(Debug, Clone, Args)]
+6
View File
@@ -128,6 +128,12 @@ impl Bookmarks {
Ok(buffer)
}
/// get bookmarknames as space separated values in one string (for shell completions)
pub fn get_bookmarknames(&self) -> String {
let mut names: Vec<String> = self.bookmarks.keys().cloned().collect();
names.join(" ")
}
/// writes the bookmarks file
fn write_bookmark_file(&self) -> Result<()> {
let mut file_content = String::new();
+1
View File
@@ -131,6 +131,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::names(_) => println!("echo '{}'", bookmarks.get_bookmarknames()),
};
} else if args.name.is_some() { // handle `change to bookmark`
let path = bookmarks.get_path_by_name(args.name.as_ref().unwrap())?;