bin: Allow to build without bugreport

This commit is contained in:
Martin Nordholts 2021-08-08 06:30:41 +02:00
parent c83e382eac
commit 905902d811

View File

@ -224,12 +224,8 @@ fn run_controller(inputs: Vec<Input>, config: &Config) -> Result<bool> {
controller.run(inputs) controller.run(inputs)
} }
/// Returns `Err(..)` upon fatal errors. Otherwise, returns `Ok(true)` on full success and #[cfg(feature = "bugreport")]
/// `Ok(false)` if any intermediate errors occurred (were printed). fn invoke_bugreport(app: &App) {
fn run() -> Result<bool> {
let app = App::new()?;
if app.matches.is_present("diagnostic") {
use bugreport::{bugreport, collector::*, format::Markdown}; use bugreport::{bugreport, collector::*, format::Markdown};
let pager = bat::config::get_pager_executable(app.matches.value_of("pager")) let pager = bat::config::get_pager_executable(app.matches.value_of("pager"))
.unwrap_or_else(|| "less".to_owned()); // FIXME: Avoid non-canonical path to "less". .unwrap_or_else(|| "less".to_owned()); // FIXME: Avoid non-canonical path to "less".
@ -269,7 +265,18 @@ fn run() -> Result<bool> {
}; };
report.print::<Markdown>(); report.print::<Markdown>();
}
/// Returns `Err(..)` upon fatal errors. Otherwise, returns `Ok(true)` on full success and
/// `Ok(false)` if any intermediate errors occurred (were printed).
fn run() -> Result<bool> {
let app = App::new()?;
if app.matches.is_present("diagnostic") {
#[cfg(feature = "bugreport")]
invoke_bugreport(&app);
#[cfg(not(feature = "bugreport"))]
println!("bat has been built without the 'bugreport' feature. The '--diagnostic' option is not available.");
return Ok(true); return Ok(true);
} }