#[cfg(any(feature = "prodash-render-line", feature = "prodash-render-tui"))] pub const DEFAULT_FRAME_RATE: f32 = 6.0; #[allow(unused)] pub type ProgressRange = std::ops::RangeInclusive; #[allow(unused)] pub const STANDARD_RANGE: ProgressRange = 2..=2; #[allow(unused)] #[cfg(feature = "prodash-render-line")] pub fn setup_line_renderer_range( progress: prodash::Tree, levels: std::ops::RangeInclusive, hide_cursor: bool, ) -> prodash::render::line::JoinHandle { let output_is_terminal = atty::is(atty::Stream::Stderr); prodash::render::line( std::io::stderr(), progress, prodash::render::line::Options { level_filter: Some(levels), frames_per_second: DEFAULT_FRAME_RATE, initial_delay: Some(std::time::Duration::from_millis(1000)), output_is_terminal, colored: output_is_terminal && crosstermion::color::allowed(), timestamp: true, hide_cursor, throughput: true, ..prodash::render::line::Options::default() }, ) } #[cfg(all(feature = "lean-cli", not(feature = "pretty-cli")))] pub fn from_env() -> T { static VERSION: &str = concat!(env!("CARGO_PKG_NAME"), " ", env!("CARGO_PKG_VERSION")); let strings: Vec = std::env::args().collect(); let strs: Vec<&str> = strings.iter().map(|s| s.as_str()).collect(); T::from_args(&[strs[0]], &strs[1..]).unwrap_or_else(|early_exit| { // This allows us to make subcommands mandatory, // and trigger a helpful message unless --version is specified if let Some(arg) = std::env::args().skip(1).next() { if arg == "--version" { println!("{}", VERSION); std::process::exit(0); } } println!("{}", early_exit.output); std::process::exit(match early_exit.status { Ok(()) => 0, Err(()) => 1, }) }) }