From 969bff4dd19b2a58cd317113c5feee98f3d2b12e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christina=20S=C3=B8rensen?= Date: Sat, 8 Jul 2023 07:53:45 +0200 Subject: [PATCH] feat(jump): done, but not great MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Of course, the calling process is different from us, and we can't actually change their PWD >_< *sigh* But, this can be put in e.g. an alias, which seems to be what most jump/cd expanding types of programs do. We are not those, so, going beyond what most of those do with ptrace and hackery is not really in scope... But ugh, I hate this. But I still want this feature for myself so ¯\_(ツ)_/¯ Signed-off-by: Christina Sørensen --- src/cli.rs | 4 ++-- src/main.rs | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 6e6c150..a9d1387 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -119,9 +119,9 @@ pub enum Commands { pub enum JumpCommands { /// Jump to repo #[command(visible_alias = "r")] - Repo { name: Option }, + Repo { category: String, name: String }, /// Jump to link #[command(visible_alias = "l")] - Link { name: Option }, + Link { category: String, name: String }, } diff --git a/src/main.rs b/src/main.rs index abb2954..cb9d792 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,7 +43,7 @@ mod settings; #[allow(unused)] mod utils; -use cli::{Args, Commands}; +use cli::{Args, Commands, JumpCommands}; use git::Config; use utils::strings::{FAST_COMMIT, QUICK_COMMIT}; @@ -107,9 +107,16 @@ fn main() { Some(Commands::CommitMsg { msg }) => { config.commit_all_msg(msg.as_ref().expect("failed to get message from input")); } - Some(Commands::Jump(_)) => { - todo!(); - } + Some(Commands::Jump(cmd)) => match cmd { + JumpCommands::Repo { category, name } => { + config.get_repo(category, name, |repo| { + println!("{}{}", repo.path, repo.name); + }); + } + JumpCommands::Link { category, name } => { + config.get_link(category, name, |link| println!("{}", link.tx)); + } + }, None => (), } trace!("{:?}", config);