diff --git a/.cargo/config.toml b/.cargo/config.toml deleted file mode 100644 index bf09108..0000000 --- a/.cargo/config.toml +++ /dev/null @@ -1 +0,0 @@ -paths = ["../xx"] diff --git a/Cargo.lock b/Cargo.lock index 4351fcd..09ddf1e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -467,7 +467,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -1443,7 +1443,7 @@ dependencies = [ "errno 0.3.10", "libc", "linux-raw-sys", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -2042,7 +2042,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.48.0", ] [[package]] @@ -2272,9 +2272,9 @@ dependencies = [ [[package]] name = "xx" -version = "2.0.0" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2c507cfdc3944bf23d0ef0fc39894bd05b566828bb961dbd1dc42e013d99f99" +checksum = "53ba8e1329637bfde9509cf8be1b3b9eed7c0130e60408a45f6d514a11f7974b" dependencies = [ "duct", "filetime", diff --git a/src/cli/activate.rs b/src/cli/activate.rs index b4b30f8..d36a3a2 100644 --- a/src/cli/activate.rs +++ b/src/cli/activate.rs @@ -1,4 +1,4 @@ -use crate::Result; +use crate::{env, Result}; /// Activate pitchfork in your shell session /// @@ -13,6 +13,21 @@ pub struct Activate { impl Activate { pub async fn run(&self) -> Result<()> { - unimplemented!(); + let s = match self.shell.as_str() { + "fish" => { + format!( + r#" +function __pitchfork --on-variable PWD + {} cd --shell-pid "$fish_pid" +end +__pitchfork +"#, + env::BIN_PATH.display() + ) + } + _ => unimplemented!(), + }; + println!("{}", s.trim()); + Ok(()) } } diff --git a/src/cli/cd.rs b/src/cli/cd.rs new file mode 100644 index 0000000..a795546 --- /dev/null +++ b/src/cli/cd.rs @@ -0,0 +1,15 @@ +use crate::Result; + +#[derive(Debug, clap::Args)] +#[clap(hide = true, verbatim_doc_comment)] +pub struct Cd { + #[clap(long)] + shell_pid: u32, +} + +impl Cd { + pub async fn run(&self) -> Result<()> { + dbg!(self); + Ok(()) + } +} diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 600c4d0..27f6068 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -3,6 +3,7 @@ use clap::Parser; mod activate; mod add; +mod cd; mod clean; mod completion; mod disable; @@ -28,6 +29,7 @@ struct Cli { enum Commands { Activate(activate::Activate), Add(add::Add), + Cd(cd::Cd), Clean(clean::Clean), Completion(completion::Completion), Disable(disable::Disable), @@ -50,6 +52,7 @@ pub async fn run() -> Result<()> { match args.command { Commands::Activate(activate) => activate.run().await, Commands::Add(add) => add.run().await, + Commands::Cd(cd) => cd.run().await, Commands::Clean(clean) => clean.run().await, Commands::Completion(completion) => completion.run().await, Commands::Disable(disable) => disable.run().await,