summaryrefslogtreecommitdiffstats
path: root/src/cli.rs
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2022-11-01 17:48:54 -0500
committerToby Vincent <tobyv13@gmail.com>2022-11-01 17:48:54 -0500
commit1334d9f1d08a27ea7fa4cd4228ac1fdf44bdd552 (patch)
tree78582f51069b7e40691e3aea78c7a93441098056 /src/cli.rs
parent698d811059ebb6787305e8293a77837323fc9311 (diff)
feat: impl ignore crate to walk directories
Diffstat (limited to 'src/cli.rs')
-rw-r--r--src/cli.rs39
1 files changed, 25 insertions, 14 deletions
diff --git a/src/cli.rs b/src/cli.rs
index 5da1036..68bc665 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -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)]