Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bin): consider env when no verbosity flag is set #1848

Merged
merged 3 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions neqo-bin/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ type Res<T> = Result<T, Error>;
#[command(author, version, about, long_about = None)]
#[allow(clippy::struct_excessive_bools)] // Not a good use of that lint.
pub struct Args {
#[command(flatten)]
verbose: clap_verbosity_flag::Verbosity<clap_verbosity_flag::InfoLevel>,

#[command(flatten)]
shared: SharedArgs,

Expand Down Expand Up @@ -180,7 +177,6 @@ impl Args {
pub fn new(requests: &[u64]) -> Self {
use std::str::FromStr;
Self {
verbose: clap_verbosity_flag::Verbosity::<clap_verbosity_flag::InfoLevel>::default(),
shared: crate::SharedArgs::default(),
urls: requests
.iter()
Expand Down Expand Up @@ -485,7 +481,12 @@ fn qlog_new(args: &Args, hostname: &str, cid: &ConnectionId) -> Res<NeqoQlog> {
}

pub async fn client(mut args: Args) -> Res<()> {
neqo_common::log::init(Some(args.verbose.log_level_filter()));
neqo_common::log::init(
args.shared
.verbose
.as_ref()
.map(clap_verbosity_flag::Verbosity::log_level_filter),
);
init()?;

args.update_for_tests();
Expand Down
4 changes: 4 additions & 0 deletions neqo-bin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ mod udp;

#[derive(Debug, Parser)]
pub struct SharedArgs {
#[command(flatten)]
verbose: Option<clap_verbosity_flag::Verbosity>,

#[arg(short = 'a', long, default_value = "h3")]
/// ALPN labels to negotiate.
///
Expand Down Expand Up @@ -66,6 +69,7 @@ pub struct SharedArgs {
impl Default for SharedArgs {
fn default() -> Self {
Self {
verbose: None,
alpn: "h3".into(),
qlog_dir: None,
max_table_size_encoder: 16384,
Expand Down
11 changes: 6 additions & 5 deletions neqo-bin/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ type Res<T> = Result<T, Error>;
#[derive(Debug, Parser)]
#[command(author, version, about, long_about = None)]
pub struct Args {
#[command(flatten)]
verbose: clap_verbosity_flag::Verbosity<clap_verbosity_flag::InfoLevel>,

#[command(flatten)]
shared: SharedArgs,

Expand Down Expand Up @@ -132,7 +129,6 @@ impl Default for Args {
fn default() -> Self {
use std::str::FromStr;
Self {
verbose: clap_verbosity_flag::Verbosity::<clap_verbosity_flag::InfoLevel>::default(),
shared: crate::SharedArgs::default(),
hosts: vec!["[::]:12345".to_string()],
db: PathBuf::from_str("../test-fixture/db").unwrap(),
Expand Down Expand Up @@ -587,7 +583,12 @@ enum Ready {
pub async fn server(mut args: Args) -> Res<()> {
const HQ_INTEROP: &str = "hq-interop";

neqo_common::log::init(Some(args.verbose.log_level_filter()));
neqo_common::log::init(
args.shared
.verbose
.as_ref()
.map(clap_verbosity_flag::Verbosity::log_level_filter),
);
assert!(!args.key.is_empty(), "Need at least one key");

init_db(args.db.clone())?;
Expand Down
Loading