Skip to content

Commit

Permalink
move image_backends into its own crate
Browse files Browse the repository at this point in the history
  • Loading branch information
o2sh committed Nov 12, 2022
1 parent 0a70a38 commit 9ce17c1
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 7 deletions.
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ rust-version = "1.60.0"
version = "2.13.2"

[workspace]
members = ["manifest"]
members = ["manifest", "image"]

[dependencies]
onefetch-manifest = { path = "manifest", version = "2.13.2" }
onefetch-image = { path = "image", version = "2.13.2" }
anyhow = "1.0.66"
askalono = "0.4.6"
byte-unit = "4.0.14"
Expand Down
16 changes: 16 additions & 0 deletions image/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
authors = ["o2sh <ossama-hjaji@live.fr>"]
name = "onefetch-image"
version = "2.13.2"
edition = "2021"
license = "MIT"
readme = "README.md"

[dependencies]
image = "0.24.4"
anyhow = "1.0"
clap = "4.0.22"

[target.'cfg(not(windows))'.dependencies]
base64 = "0.13.0"
libc = "0.2.134"
1 change: 1 addition & 0 deletions image/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../LICENSE.md
11 changes: 11 additions & 0 deletions image/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# image

Provides the primary interface to diplay images in the terminal.

Protocols supported:

- Sixel
- Kitty
- Iterm

_This crate is designed as part of the [onefetch](https://github.com/o2sh/onefetch) project._
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::info::info_field::InfoType;
use crate::info::langs::language::{Language, LanguageType};
use crate::ui::image_backends::ImageProtocol;
use crate::ui::printer::SerializationFormat;
use anyhow::Result;
use clap::builder::PossibleValuesParser;
use clap::builder::TypedValueParser as _;
use clap::{value_parser, Command, Parser, ValueHint};
use clap_complete::{generate, Generator, Shell};
use onefetch_image::ImageProtocol;
use onefetch_manifest::ManifestType;
use regex::Regex;
use std::env;
Expand Down
1 change: 0 additions & 1 deletion src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::info::langs::language::Language;
use owo_colors::{AnsiColors, DynColors};

pub mod ascii_art;
pub mod image_backends;
pub mod printer;
pub mod text_colors;

Expand Down
7 changes: 3 additions & 4 deletions src/ui/printer.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use crate::cli::{Config, When};
use crate::info::Info;
use crate::ui::ascii_art::AsciiArt;
use crate::ui::image_backends;
use crate::ui::image_backends::ImageBackend;
use crate::ui::Language;
use anyhow::{Context, Result};
use image::DynamicImage;
use onefetch_image::ImageBackend;
use std::fmt::Write as _;
use std::io::Write;
use terminal_size::{terminal_size, Width};
Expand Down Expand Up @@ -53,8 +52,8 @@ impl<W: Write> Printer<W> {
let image_backend = if image.is_some() {
config
.image_protocol
.map_or_else(image_backends::get_best_backend, |s| {
image_backends::get_image_backend(s)
.map_or_else(onefetch_image::get_best_backend, |s| {
onefetch_image::get_image_backend(s)
})
} else {
None
Expand Down

0 comments on commit 9ce17c1

Please sign in to comment.