diff --git a/crates/hyfetch/src/cli_options.rs b/crates/hyfetch/src/cli_options.rs index 90d989fb..11441dd3 100644 --- a/crates/hyfetch/src/cli_options.rs +++ b/crates/hyfetch/src/cli_options.rs @@ -7,7 +7,7 @@ use bpaf::{construct, long, OptionParser, Parser}; use strum::VariantNames; use crate::presets::Preset; -use crate::types::AnsiMode; +use crate::types::{AnsiMode, Backend}; #[derive(Clone, Debug)] pub struct Options { @@ -15,17 +15,17 @@ pub struct Options { pub config_file: Option, pub preset: Option, pub mode: Option, - // pub backend: Option, - // pub backend_args: Option, - // pub colors_scale: Option, - // pub colors_set_lightness: Option, - // pub colors_use_overlay: bool, - // pub june: bool, - // pub debug: bool, - // pub test_distro: Option, - // pub ascii_file: Option, - // pub test_print: bool, - // pub ask_exit: bool, + pub backend: Option, + pub backend_args: Option, + pub colors_scale: Option, + pub colors_set_lightness: Option, + pub colors_use_overlay: bool, + pub june: bool, + pub debug: bool, + pub test_distro: Option, + pub ascii_file: Option, + pub test_print: bool, + pub ask_exit: bool, } pub fn options() -> OptionParser { @@ -44,7 +44,7 @@ pub fn options() -> OptionParser { PRESET={{{}}}", Preset::VARIANTS.join(",") )) - .argument::("PRESET"); + .argument("PRESET"); #[cfg(feature = "autocomplete")] let preset = preset.complete(complete_preset); let preset = preset.parse(|s| Preset::from_str(&s)).optional(); @@ -55,18 +55,79 @@ PRESET={{{}}}", MODE={{{}}}", AnsiMode::VARIANTS.join(",") )) - .argument::("MODE"); + .argument("MODE"); #[cfg(feature = "autocomplete")] let mode = mode.complete(complete_mode); let mode = mode.parse(|s| AnsiMode::from_str(&s)).optional(); - // TODO + let backend = long("backend") + .short('b') + .help(&*format!( + "Choose a *fetch backend +BACKEND={{{}}}", + Backend::VARIANTS.join(",") + )) + .argument("BACKEND"); + #[cfg(feature = "autocomplete")] + let backend = backend.complete(complete_backend); + let backend = backend.parse(|s| Backend::from_str(&s)).optional(); + let backend_args = long("args") + .help("Additional arguments pass-through to backend") + .argument("ARGS") + .optional(); + let colors_scale = long("c-scale") + .help("Lighten colors by a multiplier") + .argument("SCALE") + .optional(); + let colors_set_lightness = long("c-set-l") + .help("Set lightness value of the colors") + .argument("LIGHT") + .optional(); + let colors_use_overlay = long("c-overlay") + .help("Use experimental overlay color adjusting instead of HSL lightness") + .switch(); + let june = long("june").help("Show pride month easter egg").switch(); + let debug = long("debug").help("Debug mode").switch(); + let distro = long("distro") + .help("Test for a specific distro") + .argument("DISTRO") + .optional(); + let test_distro = long("test-distro") + .help("Test for a specific distro") + .argument("DISTRO") + .optional(); + let test_distro = construct!([distro, test_distro]); + let ascii_file = long("ascii-file") + .help("Use a specific file for the ascii art") + .argument("ASCII_FILE"); + #[cfg(feature = "autocomplete")] + let ascii_file = ascii_file.complete_shell(ShellComp::Nothing); + let ascii_file = ascii_file.optional(); + let test_print = long("test-print") + .help("Print the ascii distro and exit") + .switch() + .hide(); + let ask_exit = long("ask-exit") + .help("Ask for input before exiting") + .switch() + .hide(); construct!(Options { config, config_file, preset, mode, - // TODO + backend, + backend_args, + colors_scale, + colors_set_lightness, + colors_use_overlay, + june, + debug, + test_distro, + ascii_file, + // hidden + test_print, + ask_exit, }) .to_options() .version(env!("CARGO_PKG_VERSION")) @@ -100,6 +161,20 @@ fn complete_mode(input: &String) -> Vec<(String, Option)> { .collect::>() } +#[cfg(feature = "autocomplete")] +fn complete_backend(input: &String) -> Vec<(String, Option)> { + Backend::VARIANTS + .iter() + .filter_map(|&name| { + if name.starts_with(input) { + Some((name.to_owned(), None)) + } else { + None + } + }) + .collect::>() +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/hyfetch/src/types.rs b/crates/hyfetch/src/types.rs index b0163273..263b0d0d 100644 --- a/crates/hyfetch/src/types.rs +++ b/crates/hyfetch/src/types.rs @@ -7,3 +7,12 @@ pub enum AnsiMode { Ansi256, Rgb, } + +#[derive(Clone, Eq, PartialEq, Hash, Debug, EnumString, VariantNames)] +#[strum(serialize_all = "kebab-case")] +pub enum Backend { + Qwqfetch, + Neofetch, + Fastfetch, + FastfetchOld, +}