Skip to content

Commit

Permalink
Fix windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
shuni64 committed Nov 9, 2019
1 parent c5a1e2c commit 1194f71
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 <ossama-hjaji@live.fr>")
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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<dyn ImageBackend>,
"sixel" => Box::new(image_backends::sixel::SixelBackend::new()) as Box<dyn ImageBackend>,
_ => unreachable!()
})
});
#[cfg(not(target_os = "linux"))]
let backend = None;
backend
} else {
crate::image_backends::get_best_backend()
}
Expand Down

0 comments on commit 1194f71

Please sign in to comment.