Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Dec 10, 2024
1 parent 7a0d8fa commit a528e5f
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 8 deletions.
1 change: 0 additions & 1 deletion .cargo/config.toml

This file was deleted.

10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 17 additions & 2 deletions src/cli/activate.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::Result;
use crate::{env, Result};

/// Activate pitchfork in your shell session
///
Expand All @@ -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(())
}
}
15 changes: 15 additions & 0 deletions src/cli/cd.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
}
3 changes: 3 additions & 0 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use clap::Parser;

mod activate;
mod add;
mod cd;
mod clean;
mod completion;
mod disable;
Expand All @@ -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),
Expand All @@ -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,
Expand Down

0 comments on commit a528e5f

Please sign in to comment.