improved output of book remove & added todo
This commit is contained in:
@@ -71,8 +71,9 @@ The following formats are supported:
|
|||||||
- [x] do not resolve links in bookmarks
|
- [x] do not resolve links in bookmarks
|
||||||
- [x] option to show invalid paths
|
- [x] option to show invalid paths
|
||||||
- [x] style option for invalid paths
|
- [x] style option for invalid paths
|
||||||
- [x] subcommand to remove invalid paths
|
- [x] subcommand to remove invalid paths
|
||||||
- [ ] print deleted bookmarks
|
- [ ] print deleted bookmarks
|
||||||
|
- [ ] consistent output of `remove` subcommand
|
||||||
- [x] push <number> to push path in stack
|
- [x] push <number> to push path in stack
|
||||||
- [x] write documentation
|
- [x] write documentation
|
||||||
- [x] change config file extension to `.toml`
|
- [x] change config file extension to `.toml`
|
||||||
|
|||||||
+7
-3
@@ -89,16 +89,20 @@ impl Bookmarks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// removes a the entry with key=name if it exists, then writes the bookmarks file
|
/// removes a the entry with key=name if it exists, then writes the bookmarks file
|
||||||
pub fn remove_bookmark(&mut self, name: &String) -> Result<()> {
|
pub fn remove_bookmark(&mut self, name: &String) -> Result<PathBuf> {
|
||||||
|
let path: PathBuf;
|
||||||
if self.bookmarks.contains_key(name) {
|
if self.bookmarks.contains_key(name) {
|
||||||
_ = self.bookmarks.remove(name);
|
path = match self.bookmarks.remove(name) {
|
||||||
|
Some(path) => path,
|
||||||
|
None => return Err(Error::other("-- those bastards, they lied to me!")),
|
||||||
|
};
|
||||||
self.write_bookmark_file()?;
|
self.write_bookmark_file()?;
|
||||||
} else {
|
} else {
|
||||||
return Err(Error::other(
|
return Err(Error::other(
|
||||||
"-- bookmark requested to delete does not exist",
|
"-- bookmark requested to delete does not exist",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|||||||
+2
-2
@@ -214,12 +214,12 @@ fn add_bookmarks(args: &BookmarkSubArgs, config: &Config, bookmarks: &mut Bookma
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn remove_bookmarks(args: &BookmarkSubArgs, config: &Config, bookmarks: &mut Bookmarks, output: &mut Output) -> Result<()> {
|
fn remove_bookmarks(args: &BookmarkSubArgs, config: &Config, bookmarks: &mut Bookmarks, output: &mut Output) -> Result<()> {
|
||||||
bookmarks.remove_bookmark(&args.name)?;
|
let path = bookmarks.remove_bookmark(&args.name)?;
|
||||||
|
|
||||||
if config.general.show_entries_on_bookmark {
|
if config.general.show_entries_on_bookmark {
|
||||||
output.push_info(&bookmarks.to_formatted_string(config)?);
|
output.push_info(&bookmarks.to_formatted_string(config)?);
|
||||||
} else {
|
} else {
|
||||||
output.push_info(&format!("remove bookmark `{}{}{}`.", generate_style_sequence(Some(STYLES.set.bold), None, None), args.name, RESET_SEQ));
|
output.push_info(&format!("removed bookmark `{}{}{}{}{}`.", generate_style_sequence(Some(STYLES.set.bold), None, None), args.name, config.format.bookmarks_separator, path.to_str().unwrap(), RESET_SEQ));
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user