Struct broot::verb::VerbInvocation
source · Expand description
the verb and its arguments, making the invocation. When coming from parsing, the args is Some as soon as there’s a separator (i.e. it’s “” in “cp “)
Fields§
§name: String
§args: Option<String>
§bang: bool
Implementations§
source§impl VerbInvocation
impl VerbInvocation
pub fn new<T: Into<String>>(name: T, args: Option<T>, bang: bool) -> Self
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Examples found in repository?
More examples
src/command/completion.rs (line 246)
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264
pub fn for_input(
parts: &CommandParts,
con: &AppContext,
sel_info: SelInfo<'_>,
) -> Self {
info!("Looking for completions");
match &parts.verb_invocation {
Some(invocation) if !invocation.is_empty() => {
match &invocation.args {
None => {
// looking into verb completion
Self::for_verb(&invocation.name, con, sel_info)
}
Some(args) if !args.is_empty() => {
// looking into arg completion
Self::for_arg(&invocation.name, args, con, sel_info)
}
_ => {
// nothing possible
Self::None
}
}
}
_ => Self::None, // no possible completion if no verb invocation
}
}
sourcepub fn complete_name(&self) -> String
pub fn complete_name(&self) -> String
build a new String
sourcepub fn to_string_for_name(&self, name: &str) -> String
pub fn to_string_for_name(&self, name: &str) -> String
basically return the invocation but allow another name (the shortcut or a variant)
Examples found in repository?
src/verb/invocation_parser.rs (line 118)
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
pub fn check_args(
&self,
invocation: &VerbInvocation,
_other_path: &Option<PathBuf>,
) -> Option<String> {
match (&invocation.args, &self.args_parser) {
(None, None) => None,
(None, Some(ref regex)) => {
if regex.is_match("") {
None
} else {
Some(self.invocation_pattern.to_string_for_name(&invocation.name))
}
}
(Some(ref s), Some(ref regex)) => {
if regex.is_match(s) {
None
} else {
Some(self.invocation_pattern.to_string_for_name(&invocation.name))
}
}
(Some(_), None) => Some(format!("{} doesn't take arguments", invocation.name)),
}
}
Trait Implementations§
source§impl Clone for VerbInvocation
impl Clone for VerbInvocation
source§fn clone(&self) -> VerbInvocation
fn clone(&self) -> VerbInvocation
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for VerbInvocation
impl Debug for VerbInvocation
source§impl Display for VerbInvocation
impl Display for VerbInvocation
source§impl From<&str> for VerbInvocation
impl From<&str> for VerbInvocation
source§impl PartialEq<VerbInvocation> for VerbInvocation
impl PartialEq<VerbInvocation> for VerbInvocation
source§fn eq(&self, other: &VerbInvocation) -> bool
fn eq(&self, other: &VerbInvocation) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.