diff options
author | Toby Vincent <tobyv13@gmail.com> | 2022-11-02 17:48:10 -0500 |
---|---|---|
committer | Toby Vincent <tobyv13@gmail.com> | 2022-11-02 17:48:10 -0500 |
commit | 53d0cefcb1ca3527935479cc07a6f5fe5b1f8051 (patch) | |
tree | 307ba4005e9ffe95396f07750871b6e44b4e502e /src/cli.rs | |
parent | 1334d9f1d08a27ea7fa4cd4228ac1fdf44bdd552 (diff) |
feat: finish implementing config and cli
Diffstat (limited to 'src/cli.rs')
-rw-r--r-- | src/cli.rs | 28 |
1 files changed, 10 insertions, 18 deletions
@@ -1,4 +1,3 @@ -use crate::{config::Paths, Config, Result}; use clap::{Args, Parser}; use std::path::PathBuf; use tracing_subscriber::{filter::LevelFilter, Layer, Registry}; @@ -27,28 +26,21 @@ pub struct Cli { } impl Cli { - pub fn as_layer(&self) -> Result<Vec<Box<dyn Layer<Registry> + Send + Sync>>> { - let mut layers = Vec::new(); - + pub fn as_layer(&self) -> Vec<Box<dyn Layer<Registry> + Send + Sync>> { let fmt_layer = tracing_subscriber::fmt::layer() .pretty() - .with_filter(self.verbose.into_filter()) + .with_filter(self.verbose.as_filter()) .boxed(); - layers.push(fmt_layer); - - Ok(layers) + vec![fmt_layer] } - 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(), + // 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, } } } @@ -65,7 +57,7 @@ pub struct Verbosity { } impl Verbosity { - pub fn into_filter(&self) -> LevelFilter { + pub fn as_filter(&self) -> LevelFilter { self.into() } } |