Skip to content

Commit 8067852

Browse files
committed
Cli: Derive Default
So that we can instantiate Cli to a safe default with everything disabled. Signed-off-by: Daniel Schaefer <[email protected]>
1 parent d515b02 commit 8067852

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

framework_lib/src/commandline/clap_std.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use clap_num::maybe_hex;
99
use crate::chromium_ec::commands::SetGpuSerialMagic;
1010
use crate::chromium_ec::CrosEcDriverType;
1111
use crate::commandline::{
12-
Cli, ConsoleArg, FpBrightnessArg, HardwareDeviceType, InputDeckModeArg, RebootEcArg,
12+
Cli, ConsoleArg, FpBrightnessArg, HardwareDeviceType, InputDeckModeArg, LogLevel, RebootEcArg,
1313
TabletModeArg,
1414
};
1515

@@ -335,7 +335,7 @@ pub fn parse(args: &[String]) -> Cli {
335335
};
336336

337337
Cli {
338-
verbosity: args.verbosity.log_level_filter(),
338+
verbosity: LogLevel(args.verbosity.log_level_filter()),
339339
versions: args.versions,
340340
version: args.version,
341341
features: args.features,

framework_lib/src/commandline/mod.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,22 @@ impl From<InputDeckModeArg> for DeckStateMode {
134134
}
135135
}
136136

137+
#[derive(Debug)]
138+
pub struct LogLevel(log::LevelFilter);
139+
140+
impl Default for LogLevel {
141+
fn default() -> Self {
142+
LogLevel(log::LevelFilter::Error)
143+
}
144+
}
145+
137146
/// Shadows `clap_std::ClapCli` with extras for UEFI
138147
///
139148
/// The UEFI commandline currently doesn't use clap, so we need to shadow the struct.
140149
/// Also it has extra options.
141-
#[derive(Debug)]
150+
#[derive(Debug, Default)]
142151
pub struct Cli {
143-
pub verbosity: log::LevelFilter,
152+
pub verbosity: LogLevel,
144153
pub versions: bool,
145154
pub version: bool,
146155
pub features: bool,
@@ -705,7 +714,7 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
705714
// .filter("FRAMEWORK_COMPUTER_LOG")
706715
// .write_style("FRAMEWORK_COMPUTER_LOG_STYLE");
707716

708-
let level = args.verbosity.as_str();
717+
let level = args.verbosity.0.as_str();
709718
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or(level))
710719
.format_target(false)
711720
.format_timestamp(None)

0 commit comments

Comments
 (0)