use crate::support::Protocol;
use clap::{arg, command, Parser};
use std::path::PathBuf;
#[derive(Parser)]
#[command(author, version, about)]
pub struct Options {
#[arg(num_args(1..))]
pub path: Vec<PathBuf>,
#[arg(short, long)]
pub protocol: Option<Protocol>,
#[arg(short, long)]
pub x: Option<u32>,
#[arg(short, long)]
pub y: Option<u32>,
#[arg(short, long)]
pub cols: Option<u32>,
#[arg(short, long)]
pub rows: Option<u32>,
#[arg(long)]
pub spacing: Option<u32>,
#[arg(short, long)]
pub upscale: bool,
#[arg(short, long)]
pub no_newline: bool,
#[arg(short = 's', long = "static", conflicts_with("gif_loop"))]
pub gif_static: bool,
#[arg(short = 'l', long = "loop")]
pub gif_loop: bool,
#[arg(long, value_name = "ID")]
pub load: Option<u32>,
#[arg(long, value_name = "ID")]
pub display: Option<u32>,
#[arg(long, value_name = "ID")]
pub clear: Option<u32>,
}
impl Options {
pub fn new(path: Vec<PathBuf>) -> Self {
Self {
path,
protocol: None,
x: None,
y: None,
cols: None,
rows: None,
spacing: None,
upscale: false,
gif_static: false,
gif_loop: false,
no_newline: false,
load: None,
display: None,
clear: None,
}
}
pub fn set_position(&mut self, x: Option<u32>, y: Option<u32>) {
self.x = x;
self.y = y;
}
pub fn set_size(&mut self, cols: Option<u32>, rows: Option<u32>) {
self.cols = cols;
self.rows = rows;
}
pub fn set_spacing(&mut self, spacing: Option<u32>) {
self.spacing = spacing;
}
pub fn upscale(&mut self) {
self.upscale = true;
}
pub fn no_newline(&mut self) {
self.no_newline = true;
}
pub fn set_static(&mut self) {
self.gif_static = true;
self.gif_loop = false;
}
pub fn set_loop(&mut self) {
self.gif_static = false;
self.gif_loop = true;
}
pub fn set_kitty(&mut self, load: Option<u32>, display: Option<u32>, clear: Option<u32>) {
if self.protocol == Some(Protocol::Kitty) {
self.load = load;
self.display = display;
self.clear = clear;
}
}
}