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(-) 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