diff --git a/src/main.rs b/src/main.rs index 92209da12..af368b396 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,6 +38,7 @@ mod license; use ascii_art::AsciiArt; use commit_info::CommitInfo; use error::Error; +#[cfg(target_os = "linux")] use image_backends::ImageBackend; use info::Info; use language::Language; @@ -100,6 +101,11 @@ fn main() -> Result<()> { .map(|language| language.to_string().to_lowercase()) .collect(); + #[cfg(target_os = "linux")] + let possible_backends = ["kitty", "sixel"]; + #[cfg(not(target_os = "linux"))] + let possible_backends = []; + let matches = App::new(crate_name!()) .version(crate_version!()) .author("o2sh ") @@ -197,7 +203,7 @@ Possible values: [{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}]", Arg::with_name("image-backend") .long("image-backend") .takes_value(true) - .possible_values(&["kitty", "sixel"]) + .possible_values(&possible_backends) .help("Overrides image backend detection"), ) .arg( @@ -269,11 +275,14 @@ Possible values: [{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}]", let image_backend = if custom_image.is_some() { if let Some(backend_name) = matches.value_of("image-backend") { #[cfg(target_os = "linux")] - Some(match backend_name { + let backend = Some(match backend_name { "kitty" => Box::new(image_backends::kitty::KittyBackend::new()) as Box, "sixel" => Box::new(image_backends::sixel::SixelBackend::new()) as Box, _ => unreachable!() - }) + }); + #[cfg(not(target_os = "linux"))] + let backend = None; + backend } else { crate::image_backends::get_best_backend() }