diff options
Diffstat (limited to 'src/cli.rs')
-rw-r--r-- | src/cli.rs | 41 |
1 files changed, 28 insertions, 13 deletions
@@ -2,24 +2,32 @@ use clap::{Args, Parser}; use std::path::PathBuf; use tracing_subscriber::{filter::LevelFilter, Layer, Registry}; +use crate::paths::PathEntry; + /// Simple program to manage projects and ssh hosts using tmux #[derive(Parser, Debug)] #[command(author, version, about)] pub struct Cli { - /// Path to search recursively for directories + /// Path to directories pub(crate) path: Vec<PathBuf>, - /// Add additional directory to search results. Can be specified multiple times - #[arg(short, long)] - pub(crate) directory: Vec<PathBuf>, - - #[command(flatten)] - pub verbose: Verbosity, + /// Max depth to recurse. + /// + /// By default, no limit is set. Setting to 0 will only use the supplied directory. + #[arg(short = 'd', long)] + pub(crate) max_depth: Option<usize>, - /// Allows traversal into hidden directories when searching + /// Recurse into hidden directories. + /// + /// Include hidden directories when traversing directories. (default: hidden directories + /// are skipped). A Directory is considered to be hidden if its name starts with a `.` + /// sign (dot). If `max-depth` is set to 0, this has no effect (As no recursion happens). #[arg(long)] pub(crate) hidden: bool, + #[command(flatten)] + pub verbose: Verbosity, + /// Connect to ssh host #[arg(short, long)] pub ssh: Option<String>, @@ -36,11 +44,18 @@ impl Cli { } // TODO: replace this with `impl Figment for Cli` - pub fn as_config(&self) -> crate::directories::Config { - crate::directories::Config { - search: self.path.to_owned(), - add: self.directory.to_owned(), - hidden: self.hidden, + pub fn as_config(&self) -> crate::paths::Config { + crate::paths::Config { + paths: self + .path + .to_owned() + .into_iter() + .map(|p| PathEntry { + path: p, + hidden: self.hidden, + recurse: self.max_depth, + }) + .collect(), } } } |