added shell completions for push and bookmarks
This commit is contained in:
@@ -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)]
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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())?;
|
||||
|
||||
Reference in New Issue
Block a user