use crate::ClarMatches;
use antex::{ColorMode, StyledText, Text};
use std::path::Path;
pub fn get_app_and_args() -> (String, Vec<String>) {
let mut args = std::env::args();
let name = Path::new(&args.next().expect("expected at least one argument"))
.file_name()
.expect("expected file name")
.display()
.to_string();
(name, args.collect())
}
pub fn get_first_value(matches: &ClarMatches, name: &str) -> Option<String> {
matches.get_values(name).first().cloned().flatten()
}
pub fn get_more_info_hint(cm: ColorMode, options: &[impl AsRef<str>]) -> Text {
let mut text = Text::new(cm).s("For more information, try ");
for (index, option) in options.iter().enumerate() {
if index > 0 {
text += " or "
}
text += Text::new(cm)
.s("'")
.bright_cyan()
.bold()
.s(option.as_ref())
.reset()
.s("'");
}
text
}