1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use crate::options::Options;
use crate::result::Result;
use crate::support::Protocol;
use std::io::Write;
mod blocks;
mod iterm;
mod kitty;
mod sixel;
pub fn preview(stdout: &mut impl Write, options: &mut Options) -> Result {
let protocol = Protocol::choose(options);
let image_paths = options.path.clone();
if options.y.is_some() && image_paths.len() > 1 {
options.y = None;
}
for image_path in &image_paths {
if image_path.is_dir() {
continue;
}
match protocol {
Protocol::Kitty => kitty::preview(stdout, image_path, options)?,
Protocol::Iterm => iterm::preview(stdout, image_path, options)?,
Protocol::Sixel => sixel::preview(stdout, image_path, options)?,
Protocol::Blocks => blocks::preview(stdout, image_path, options)?,
}
}
Ok(())
}