Skip to content

Commit

Permalink
Fix --no-user-output not working anymore
Browse files Browse the repository at this point in the history
Conversion of the output format argument was only happening for `Context` but
not for the direct access in `cargo-msrv.rs`.
  • Loading branch information
Marcono1234 committed Aug 8, 2024
1 parent e8520a3 commit cf8347b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/bin/cargo-msrv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn setup_reporter(opts: CargoMsrvOpts) -> Result<ExitCode, SetupError> {

tracing::info!("storyteller channel created");

let output_format = opts.shared_opts.user_output_opts.output_format;
let output_format = opts.shared_opts.user_output_opts.effective_output_format();
let handler = WrappingHandler::from(output_format);
let finalizer = listener.run_handler(Arc::new(handler));
tracing::info!("storyteller started handler");
Expand Down
14 changes: 12 additions & 2 deletions src/cli/shared_opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,21 @@ pub struct UserOutputOpts {
value_name = "FORMAT",
global = true
)]
pub output_format: OutputFormat,
output_format: OutputFormat,

Check warning on line 36 in src/cli/shared_opts.rs

View check run for this annotation

Codecov / codecov/patch

src/cli/shared_opts.rs#L36

Added line #L36 was not covered by tests

/// Disable user output
#[arg(long, global = true)]
pub no_user_output: bool,
no_user_output: bool,

Check warning on line 40 in src/cli/shared_opts.rs

View check run for this annotation

Codecov / codecov/patch

src/cli/shared_opts.rs#L40

Added line #L40 was not covered by tests
}

impl UserOutputOpts {
pub fn effective_output_format(&self) -> OutputFormat {
if self.no_user_output {
OutputFormat::None

Check warning on line 46 in src/cli/shared_opts.rs

View check run for this annotation

Codecov / codecov/patch

src/cli/shared_opts.rs#L46

Added line #L46 was not covered by tests
} else {
self.output_format
}
}
}

#[derive(Debug, Args)]
Expand Down
10 changes: 2 additions & 8 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,8 @@ pub struct UserOutputContext {

impl From<UserOutputOpts> for UserOutputContext {
fn from(opts: UserOutputOpts) -> Self {
if opts.no_user_output {
Self {
output_format: OutputFormat::None,
}
} else {
Self {
output_format: opts.output_format,
}
Self {
output_format: opts.effective_output_format(),
}
}
}
Expand Down

0 comments on commit cf8347b

Please sign in to comment.