From f82011e76af9210c1c55b7e202df25eb22389942 Mon Sep 17 00:00:00 2001 From: Yoichi Nakayama Date: Thu, 15 Oct 2020 19:10:01 +0900 Subject: [PATCH 1/3] Enable image backends on macOS --- Cargo.toml | 2 +- src/onefetch/cli.rs | 4 ++-- src/onefetch/image_backends/mod.rs | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0f347731b..a85eb1a7b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ error-chain = "0.12" [target.'cfg(windows)'.dependencies] ansi_term = "0.12" -[target.'cfg(target_os = "linux")'.dependencies] +[target.'cfg(not(target_os = "windows"))'.dependencies] libc = "0.2.79" base64 = "0.13.0" diff --git a/src/onefetch/cli.rs b/src/onefetch/cli.rs index 17be3a997..f0d54610a 100644 --- a/src/onefetch/cli.rs +++ b/src/onefetch/cli.rs @@ -26,9 +26,9 @@ pub struct Cli { impl Cli { /// Build `Options` from command line arguments. pub fn new() -> Result { - #[cfg(target_os = "linux")] + #[cfg(not(target_os = "windows"))] let possible_backends = ["kitty", "sixel"]; - #[cfg(not(target_os = "linux"))] + #[cfg(target_os = "windows")] let possible_backends = []; let matches = App::new(crate_name!()) diff --git a/src/onefetch/image_backends/mod.rs b/src/onefetch/image_backends/mod.rs index 0fb37aa11..b65b4a61f 100644 --- a/src/onefetch/image_backends/mod.rs +++ b/src/onefetch/image_backends/mod.rs @@ -1,15 +1,15 @@ use image::DynamicImage; -#[cfg(target_os = "linux")] +#[cfg(not(target_os = "windows"))] pub mod kitty; -#[cfg(target_os = "linux")] +#[cfg(not(target_os = "windows"))] pub mod sixel; pub trait ImageBackend { fn add_image(&self, lines: Vec, image: &DynamicImage) -> String; } -#[cfg(target_os = "linux")] +#[cfg(not(target_os = "windows"))] pub fn get_best_backend() -> Option> { if kitty::KittyBackend::supported() { Some(Box::new(kitty::KittyBackend::new())) @@ -21,18 +21,18 @@ pub fn get_best_backend() -> Option> { } pub fn get_image_backend(backend_name: &str) -> Option> { - #[cfg(target_os = "linux")] + #[cfg(not(target_os = "windows"))] let backend = Some(match backend_name { "kitty" => Box::new(kitty::KittyBackend::new()) as Box, "sixel" => Box::new(sixel::SixelBackend::new()) as Box, _ => unreachable!(), }); - #[cfg(not(target_os = "linux"))] + #[cfg(target_os = "windows")] let backend = None; backend } -#[cfg(not(target_os = "linux"))] +#[cfg(target_os = "windows")] pub fn get_best_backend() -> Option> { None } From 0cf7398bdb84dd281d888f970e88a47ace4bbebf Mon Sep 17 00:00:00 2001 From: Yoichi Nakayama Date: Fri, 16 Oct 2020 06:53:56 +0900 Subject: [PATCH 2/3] Replace condition: target_os = "windows" -> windows --- src/onefetch/cli.rs | 4 ++-- src/onefetch/image_backends/mod.rs | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/onefetch/cli.rs b/src/onefetch/cli.rs index f0d54610a..9d5b95efa 100644 --- a/src/onefetch/cli.rs +++ b/src/onefetch/cli.rs @@ -26,9 +26,9 @@ pub struct Cli { impl Cli { /// Build `Options` from command line arguments. pub fn new() -> Result { - #[cfg(not(target_os = "windows"))] + #[cfg(not(windows))] let possible_backends = ["kitty", "sixel"]; - #[cfg(target_os = "windows")] + #[cfg(windows)] let possible_backends = []; let matches = App::new(crate_name!()) diff --git a/src/onefetch/image_backends/mod.rs b/src/onefetch/image_backends/mod.rs index b65b4a61f..676004a58 100644 --- a/src/onefetch/image_backends/mod.rs +++ b/src/onefetch/image_backends/mod.rs @@ -1,15 +1,15 @@ use image::DynamicImage; -#[cfg(not(target_os = "windows"))] +#[cfg(not(windows))] pub mod kitty; -#[cfg(not(target_os = "windows"))] +#[cfg(not(windows))] pub mod sixel; pub trait ImageBackend { fn add_image(&self, lines: Vec, image: &DynamicImage) -> String; } -#[cfg(not(target_os = "windows"))] +#[cfg(not(windows))] pub fn get_best_backend() -> Option> { if kitty::KittyBackend::supported() { Some(Box::new(kitty::KittyBackend::new())) @@ -21,18 +21,18 @@ pub fn get_best_backend() -> Option> { } pub fn get_image_backend(backend_name: &str) -> Option> { - #[cfg(not(target_os = "windows"))] + #[cfg(not(windows))] let backend = Some(match backend_name { "kitty" => Box::new(kitty::KittyBackend::new()) as Box, "sixel" => Box::new(sixel::SixelBackend::new()) as Box, _ => unreachable!(), }); - #[cfg(target_os = "windows")] + #[cfg(windows)] let backend = None; backend } -#[cfg(target_os = "windows")] +#[cfg(windows)] pub fn get_best_backend() -> Option> { None } From fdffb6584fc6dc77dcc91cf53390a3a952bac14b Mon Sep 17 00:00:00 2001 From: Yoichi Nakayama Date: Fri, 16 Oct 2020 07:01:20 +0900 Subject: [PATCH 3/3] Replace condition in Cargo.toml: target_os = "windows" -> windows --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index a85eb1a7b..d4108bd79 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ error-chain = "0.12" [target.'cfg(windows)'.dependencies] ansi_term = "0.12" -[target.'cfg(not(target_os = "windows"))'.dependencies] +[target.'cfg(not(windows))'.dependencies] libc = "0.2.79" base64 = "0.13.0"