Skip to content

Commit

Permalink
add clip command
Browse files Browse the repository at this point in the history
  • Loading branch information
VoltaireNoir committed Sep 17, 2023
1 parent a15f189 commit fa3d968
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/main.rs
Expand Up @@ -13,6 +13,7 @@ use std::{
use tabled::{builder::Builder, settings::Style};

const DB_PATH: Lazy<PathBuf> = Lazy::new(db_path);
const CLIPNAME: &'static str = "markd-temp";

#[derive(Parser)]
#[command(name = "Markd")]
Expand Down Expand Up @@ -47,7 +48,16 @@ enum Commands {
alias = "g",
about = "Get bookmark's path (use with cd and command substitution)"
)]
Get { bookmark: String },
Get {
#[arg(default_value_t = String::from(CLIPNAME))]
bookmark: String,
},
#[command(
alias = "c",
about = "Save temp entry for quick access with `markd get` or `goto`",
long_about = "Save current or provided directory to 'markd-temp' entry for quick switching. The saved entry will be used when no bookmark name is provided to `markd get` command"
)]
Clip,
#[command(alias = "r", about = "Remove given directory entry from bookmarks")]
Remove { bookmark: String },
}
Expand Down Expand Up @@ -79,6 +89,7 @@ fn run() -> Result<()> {
} => list(&bookmarks, Filters { filter, start, end }, path),
Commands::Purge => purge(&mut bookmarks)?,
Commands::Get { bookmark } => get(&bookmarks, &bookmark)?,
Commands::Clip => mark(&mut bookmarks, args.path, Some(CLIPNAME.into()))?,
Commands::Remove { bookmark } => remove(&mut bookmarks, &bookmark)?,
}
} else {
Expand All @@ -105,7 +116,7 @@ fn mark(

let msg = match bookmarks.get_mut(&name) {
Some(val) => {
if update() {
if name == CLIPNAME || update() {
val.clear();
val.push_str(&path);
"bookmark entry updated"
Expand Down

0 comments on commit fa3d968

Please sign in to comment.