pub struct Verb {
pub names: Vec<String>,
pub keys: Vec<KeyEvent>,
pub keys_desc: String,
pub invocation_parser: Option<InvocationParser>,
pub execution: VerbExecution,
pub description: VerbDescription,
pub selection_condition: SelectionType,
pub needs_selection: bool,
pub needs_another_panel: bool,
pub auto_exec: bool,
pub show_in_doc: bool,
}
Expand description
what makes a verb.
Verbs are the engines of broot commands, and apply
- to the selected file (if user-defined, then must contain {file}, {parent} or {directory})
- to the current app state There are two types of verbs executions:
- external programs or commands (cd, mkdir, user defined commands, etc.)
- internal behaviors (focusing a path, going back, showing the help, etc.) Some verbs are builtins, some other ones are created by configuration. Both builtins and configured vers can be internal or external based.
Fields
names: Vec<String>
names (like “cd”, “focus”, “focus_tab”, “c”) by which a verb can be called. Can be empty if the verb is only called with a key shortcut. Right now there’s no way for it to contain more than 2 elements but this may change.
keys: Vec<KeyEvent>
key shortcuts
keys_desc: String
description of the optional keyboard key(s) triggering that verb
invocation_parser: Option<InvocationParser>
how the input must be checked and interpreted Can be empty if the verb is only called with a key shortcut.
execution: VerbExecution
how the verb will be executed
description: VerbDescription
a description
selection_condition: SelectionType
the type of selection this verb applies to
needs_selection: bool
whether the verb needs a selection
needs_another_panel: bool
whether we need to have a secondary panel for execution (which is the case when the execution pattern has {other-panel-file})
auto_exec: bool
if true (default) verbs are directly executed when triggered with a keyboard shortcut
show_in_doc: bool
whether to show the verb in help screen (if we show all input related actions, the doc is unusable)
Implementations
pub fn new(
invocation_str: Option<&str>,
execution: VerbExecution,
description: VerbDescription
) -> Result<Self, ConfError>
pub fn check_args(
&self,
sel_info: &SelInfo<'_>,
invocation: &VerbInvocation,
other_path: &Option<PathBuf>
) -> Option<String>
pub fn check_args(
&self,
sel_info: &SelInfo<'_>,
invocation: &VerbInvocation,
other_path: &Option<PathBuf>
) -> Option<String>
Assuming the verb has been matched, check whether the arguments are OK according to the regex. Return none when there’s no problem and return the error to display if arguments don’t match.
pub fn get_status_markdown(
&self,
sel_info: SelInfo<'_>,
app_state: &AppState,
invocation: &VerbInvocation
) -> String
in case the verb take only one argument of type path, return the selection type of this unique argument