Skip to content

Commit e3b4114

Browse files
committed
✨ Add colour support
1 parent 9eca3bf commit e3b4114

File tree

5 files changed

+32
-5
lines changed

5 files changed

+32
-5
lines changed

Cargo.lock

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ regex = "1"
1818
home = "0.5.3"
1919
chrono = "0.4"
2020
substring = "1.4.5"
21+
colored = "2"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Rust Bookmark (d)Menu is a dmenu/ncurses based interface to manage bookmarks ind
44

55
## Features
66
- Insert Bookmark
7-
- List Bookmark(s)
7+
- List Bookmark(s) \[With coloured output]
88

99
## FAQ
1010
**Location of Bookmark file ?**

src/commands.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ pub fn list(data: Data, config: Config) {
3939
print_bookmark(&search_results);
4040
}
4141

42-
/// Print all bookmarks in the vector
42+
/// Print all bookmarks in the vector (in color)
4343
fn print_bookmark(input: &Vec<Bookmark>) {
4444
for i in input {
45-
println!("{}", i);
45+
i.colored_fmt();
4646
}
4747
}

src/data.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
use chrono::prelude::Local;
2+
use colored::*;
13
use home::home_dir;
24
use serde::{Deserialize, Serialize};
35
use std::fmt;
46
use std::fs;
57
use substring::Substring;
6-
use chrono::prelude::Local;
78

8-
use super::parser::{is_url,get_domain_name};
9+
use super::parser::{get_domain_name, is_url};
910

1011
#[derive(Serialize, Deserialize, Debug)]
1112
pub struct Bookmark {
@@ -45,6 +46,19 @@ impl Bookmark {
4546
id: id,
4647
}
4748
}
49+
50+
/// Print a coloured output
51+
/// id -> yellow bold
52+
/// name -> cyan bold
53+
/// link -> blue
54+
pub fn colored_fmt(&self) {
55+
println!(
56+
"{} {} {}",
57+
self.id.to_string().yellow().bold(),
58+
self.name.cyan().bold(),
59+
self.link.blue()
60+
);
61+
}
4862
}
4963

5064
impl fmt::Display for Bookmark {

0 commit comments

Comments
 (0)