1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use clap::Parser;
use rustutils_runnable::Runnable;
use std::error::Error;
#[derive(Parser, Clone, Debug)]
#[clap(author, version, about, long_about = None)]
pub struct Pwd {
#[clap(short = 'L', long)]
logical: bool,
#[clap(short = 'P', long)]
physical: bool,
}
impl Runnable for Pwd {
fn run(&self) -> Result<(), Box<dyn Error>> {
let normalize = match (self.logical, self.physical) {
(true, false) => false,
_ => true,
};
let dir = std::env::current_dir()?;
let dir = if normalize { dir.canonicalize()? } else { dir };
println!("{}", dir.display());
Ok(())
}
}