diff options
Diffstat (limited to 'src/cli.rs')
-rw-r--r-- | src/cli.rs | 39 |
1 files changed, 25 insertions, 14 deletions
@@ -1,22 +1,29 @@ -use crate::{Config, Result}; +use crate::{config::Paths, Config, Result}; use clap::{Args, Parser}; -use std::fs::File; -use std::sync::Arc; +use std::path::PathBuf; use tracing_subscriber::{filter::LevelFilter, Layer, Registry}; /// 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 + 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, + /// Allows traversal into hidden directories when searching + #[arg(long)] + pub(crate) hidden: bool, + /// Connect to ssh host #[arg(short, long)] pub ssh: Option<String>, - - #[command(flatten)] - pub config: Config, } impl Cli { @@ -30,16 +37,20 @@ impl Cli { layers.push(fmt_layer); - if self.config.enable_logging { - let file = File::create(&self.config.log_file)?; - let log_layer = tracing_subscriber::fmt::layer() - .with_writer(Arc::new(file)) - .boxed(); - layers.push(log_layer); - }; - Ok(layers) } + + pub fn as_config(&self) -> Config { + Config { + paths: Paths { + search: self.path.to_owned(), + add: self.directory.to_owned(), + hidden: self.hidden, + }, + finder: Default::default(), + logging: Default::default(), + } + } } #[derive(Debug, Default, Args)] |