main.rs
This file
Path
src/main.rs
72 lines · 1.9 KiB · Rust
Last changed by
Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
History of this fileTake it
The walk stopped after 200 commits: lines older than ab5ae5f point at it.
Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 1–6why, one step back1#![cfg_attr(2 all(windows, feature = "windows_process_extensions_main_thread_handle"),3 feature(windows_process_extensions_main_thread_handle)4)]56use std::env;Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
line 7why, one step back7use std::io::{self, Write};Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 8–11why, one step back89use benchmark::scheduler::Scheduler;10use cli::get_cli_arguments;11use command::Commands;Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
line 12why, one step back12use error::ConsoleOutputError;Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 13–23why, one step back13use export::ExportManager;14use options::Options;1516use anyhow::Result;17use colored::*;1819pub mod benchmark;20pub mod cli;21pub mod command;22pub mod error;23pub mod export;Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
line 24why, one step back24pub mod metric;Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 25–28why, one step back25pub mod options;26pub mod outlier_detection;27pub mod output;28pub mod parameter;Merge pull request #967 from sharkdp/codex/quantity-formattingDavid Peterbefore adoptiona6c3010
line 29why, one step back29pub mod quantity;Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 30–38why, one step back30pub mod timer;31pub mod util;3233fn run() -> Result<()> {34 // Enabled ANSI colors on Windows 1035 #[cfg(windows)]36 colored::control::set_virtual_terminal(true).unwrap();3738 let cli_arguments = get_cli_arguments(env::args_os());Multiple output policiesDavid Peterbefore adoption99d24b7
line 39why, one step back39 let mut options = Options::from_cli_arguments(&cli_arguments)?;Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
line 40why, one step back40 let commands = Commands::from_cli_arguments(&cli_arguments)?;Merge pull request #950 from Likio3000/codex/preserve-exports-on-invalid-optionsDavid Peterbefore adoptiond3d67fc
lines 41–42why, one step back41 options.validate_against_command_list(&commands)?;42Alternative performance metrics in the terminal (#986)David Peterbefore adoptionbdbfae9
line 43why, one step back43 let export_manager = ExportManager::from_cli_arguments(&cli_arguments, options.metrics[0])?;Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 44–51why, one step back4445 let mut scheduler = Scheduler::new(&commands, &options, &export_manager);46 scheduler.run_benchmarks()?;47 scheduler.final_export()?;4849 Ok(())50}51Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
lines 52–57why, one step back52fn caused_by_broken_console_pipe(error: &anyhow::Error) -> bool {53 error54 .downcast_ref::<ConsoleOutputError>()55 .is_some_and(|e| e.0.kind() == io::ErrorKind::BrokenPipe)56}57Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 58–61why, one step back58fn main() {59 match run() {60 Ok(_) => {}61 Err(e) => {Handle broken pipe errors on stdout gracefully (#932)jkbefore adoptionc0b3834
lines 62–68why, one step back62 // Exit quietly when a reader stops consuming console output early.63 if caused_by_broken_console_pipe(&e) {64 std::process::exit(0);65 }66 // The write to stderr can itself fail if stderr is closed; the67 // error message cannot be shown in that case anyway.68 let _ = writeln!(io::stderr(), "{} {:#}", "Error:".red(), e);Bump clap_complete from 4.2.0 to 4.2.1dependabot[bot]before adoptionab5ae5f
lines 69–72why, one step back69 std::process::exit(1);70 }71 }72}