forked from o2sh/onefetch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
12 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]>") | ||
|
@@ -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<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() | ||
} | ||
|