use std::ffi::OsStr;
use std::ffi::OsString;
use clap::builder::StyledStr;
#[derive(Default, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct CompletionCandidate {
content: OsString,
help: Option<StyledStr>,
hidden: bool,
}
impl CompletionCandidate {
pub fn new(content: impl Into<OsString>) -> Self {
let content = content.into();
Self {
content,
..Default::default()
}
}
pub fn help(mut self, help: Option<StyledStr>) -> Self {
self.help = help;
self
}
pub fn hide(mut self, hidden: bool) -> Self {
self.hidden = hidden;
self
}
pub fn add_prefix(mut self, prefix: impl Into<OsString>) -> Self {
let suffix = self.content;
let mut content = prefix.into();
content.push(&suffix);
self.content = content;
self
}
}
impl CompletionCandidate {
pub fn get_content(&self) -> &OsStr {
&self.content
}
pub fn get_help(&self) -> Option<&StyledStr> {
self.help.as_ref()
}
pub fn is_hide_set(&self) -> bool {
self.hidden
}
}