Add log level parameters to CLI (untested)
This commit is contained in:
parent
058830e510
commit
c25e0264b4
@ -1,3 +1,5 @@
|
||||
use clap::ValueEnum;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct Logger {
|
||||
pub level: LogLevel,
|
||||
@ -17,13 +19,13 @@ impl Logger {
|
||||
println!("{}", message.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
define_log_function!(info, Info);
|
||||
define_log_function!(debug, Debug);
|
||||
define_log_function!(error, Error);
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Default)]
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Default, ValueEnum)]
|
||||
pub enum LogLevel {
|
||||
Debug,
|
||||
#[default]
|
||||
|
||||
11
src/main.rs
11
src/main.rs
@ -6,7 +6,7 @@ mod logger;
|
||||
|
||||
use crate::action::{Action, FileAction, ServerActions};
|
||||
use crate::file::{FileMatcher, FileNameInfo};
|
||||
use crate::logger::Logger;
|
||||
use crate::logger::{LogLevel, Logger};
|
||||
use crate::os_string_builder::ReplaceWithOsStr;
|
||||
use clap::{Parser, Subcommand, ValueEnum};
|
||||
use lazy_regex::{lazy_regex, Lazy, Regex};
|
||||
@ -43,6 +43,15 @@ struct Args {
|
||||
/// The ssh names and optionally home directories of the servers to perform the action on
|
||||
#[arg(num_args = 1.., value_parser = ServerReference::from_str)]
|
||||
servers: Vec<ServerReference>,
|
||||
/// How verbose logging output should be
|
||||
#[arg(long, conflicts_with_all = ["quiet", "info"], default_value = "info")]
|
||||
log_level: Option<LogLevel>,
|
||||
/// Only log errors
|
||||
#[arg(short, long, default_value = "false")]
|
||||
quiet: bool,
|
||||
/// Log additional debugging info
|
||||
#[arg(short='v', long, default_value = "false")]
|
||||
info: bool,
|
||||
}
|
||||
|
||||
#[derive(Subcommand, Debug)]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user