From b6b74ef40480d86d81bf69467aecb4931750d1de Mon Sep 17 00:00:00 2001 From: lukeflo Date: Sun, 6 Jul 2025 13:35:07 +0200 Subject: colored version function --- src/cliargs.rs | 49 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 14 deletions(-) (limited to 'src/cliargs.rs') diff --git a/src/cliargs.rs b/src/cliargs.rs index 114b15a..46c3012 100644 --- a/src/cliargs.rs +++ b/src/cliargs.rs @@ -16,9 +16,11 @@ ///// use color_eyre::eyre::Result; -use color_eyre::owo_colors::OwoColorize; use dirs::{config_dir, home_dir}; use lexopt::prelude::*; +use owo_colors::colors::css::LightGreen; +use owo_colors::colors::*; +use owo_colors::OwoColorize; use std::env; use std::path::PathBuf; use walkdir::WalkDir; @@ -142,19 +144,38 @@ FLAGS: help } -pub fn version_func() -> String { - let version = format!( - "\ -{} {} -{} -{} +// pub fn version_func() -> String { +// let version = format!( +// "\ +// {} {} +// {} +// {} -Target Triple: {}", - env!("CARGO_PKG_NAME"), - env!("CARGO_PKG_VERSION"), - env!("CARGO_PKG_AUTHORS"), - env!("CARGO_PKG_LICENSE"), - env!("TARGET") - ); +// Target Triple: {}", +// env!("CARGO_PKG_NAME"), +// env!("CARGO_PKG_VERSION"), +// env!("CARGO_PKG_AUTHORS"), +// env!("CARGO_PKG_LICENSE"), +// env!("TARGET") +// ); +// version +// } +pub fn version_func() -> String { + let version: Vec = vec![ + format!( + "{} {}", + env!("CARGO_PKG_NAME").fg::().bold(), + env!("CARGO_PKG_VERSION").fg::() + ), + format!("{}", env!("CARGO_PKG_AUTHORS").bold()), + format!("{}", env!("CARGO_PKG_LICENSE")), + format!("\n"), + format!( + "{} {}", + "Target Triple:".bold(), + env!("TARGET").fg::() + ), + ]; + let version = version.join("\n"); version } -- cgit v1.2.3 From c0970da999e222cadbcc2242fb67686ed5b00ca4 Mon Sep 17 00:00:00 2001 From: lukeflo Date: Sun, 6 Jul 2025 14:41:36 +0200 Subject: colored help and version --- src/cliargs.rs | 100 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 57 insertions(+), 43 deletions(-) (limited to 'src/cliargs.rs') diff --git a/src/cliargs.rs b/src/cliargs.rs index 46c3012..082ecda 100644 --- a/src/cliargs.rs +++ b/src/cliargs.rs @@ -114,52 +114,66 @@ pub fn parse_files(args: Vec) -> Vec { } pub fn help_func() -> String { - let help = format!( - "\ -{} {} - -USAGE: - bibiman [FLAGS] [files/dirs] - -POSITIONAL ARGS: - Path to .bib file - Path to directory containing .bib files - - Both can be passed multiple times - -FLAGS: - -h, --help Show this help and exit - -v, --version Show the version and exit - -c, --config-file= Path to config file used for current session. - Takes precedence over standard config file. - --light-terminal Enable color mode for light terminal background - --pdf-path= Use PDF files named by citekey at the given path and its - subdirs as value for the `file` field of the entry matching - the citekey for the current session. - Does not overwrite or change the original file. - (might not work with citekeys containing special chars)", - env!("CARGO_PKG_NAME"), - env!("CARGO_PKG_VERSION"), - ); + let help = vec![ + format!( + "{} {}\n", + env!("CARGO_PKG_NAME").fg::().bold(), + env!("CARGO_PKG_VERSION").fg::(), + ), + format!( + "{}:\n\t{} [Flags] [files/dirs]\n", + "USAGE".bold(), + "bibiman".bold() + ), + format!( + "{}:\n\t{}\t\tPath to {} file", + "POSITIONAL ARGUMENTS".bold(), + "".fg::().bold(), + ".bib".fg::().bold() + ), + format!( + "\t{}\tPath to directory containing {} files", + "".fg::().bold(), + ".bib".fg::().bold() + ), + format!("\n\t{}", "Both can be passed multiple times".italic()), + format!("\n{}:", "FLAGS".bold()), + format!("\t{}", "-h, --help".bold().fg::()), + format!("\t\t{}", "Show this help and exit"), + format!("\t{}", "-v, --version".bold().fg::()), + format!("\t\t{}", "Show the version and exit"), + format!("\t{}", "--light-terminal".bold().fg::()), + format!( + "\t\t{}", + "Enable default colors for light terminal background" + ), + format!( + "\t{}{}", + "-c, --config-file=".bold().fg::(), + "".bold().italic().fg::() + ), + format!("\t\t{}", "Path to config file used for current session."), + format!("\t\t{}", "Takes precedence over standard config file."), + format!( + "\t{}{}", + "--pdf-path=".bold().fg::(), + "".bold().italic().fg::() + ), + format!("\t\t{}", "Path to directory containing PDF files."), + format!( + "\t\t{}", + "If the pdf files basename matches an entrys citekey," + ), + format!( + "\t\t{}", + "its attached as connected PDF file for the current session." + ), + format!("\t\t{}", "Does not edit the bibfile itself!"), + ]; + let help = help.join("\n"); help } -// pub fn version_func() -> String { -// let version = format!( -// "\ -// {} {} -// {} -// {} - -// Target Triple: {}", -// env!("CARGO_PKG_NAME"), -// env!("CARGO_PKG_VERSION"), -// env!("CARGO_PKG_AUTHORS"), -// env!("CARGO_PKG_LICENSE"), -// env!("TARGET") -// ); -// version -// } pub fn version_func() -> String { let version: Vec = vec![ format!( -- cgit v1.2.3