summaryrefslogtreecommitdiffstats
path: root/src/verb/invocation_parser.rs
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2022-06-30 20:39:34 +0200
committerCanop <cano.petrole@gmail.com>2022-06-30 20:39:34 +0200
commit60c29ed5571ab3def5869af31e9410e58863f76f (patch)
tree204a80e9f946d8c06abda029b66dc83e0b60ae92 /src/verb/invocation_parser.rs
parent03f5270cd3bf6a9a126d57e3dce1d1dcc20589d6 (diff)
add the set_syntax_theme verb
which isn't useful right now as the theme isn't persisted. It's an addition for a future use.
Diffstat (limited to 'src/verb/invocation_parser.rs')
-rw-r--r--src/verb/invocation_parser.rs17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/verb/invocation_parser.rs b/src/verb/invocation_parser.rs
index b850a63..78f848b 100644
--- a/src/verb/invocation_parser.rs
+++ b/src/verb/invocation_parser.rs
@@ -28,20 +28,11 @@ pub struct InvocationParser {
/// invocation name's characters are [_0-9a-zA-Z.\[\]])
args_parser: Option<Regex>,
- // //// whether the path, when non absolute, should be interpreted
- // //// as relative to the closest directory (which may be the selection)
- // //// or to the parent of the selection
- // /pub arg_anchor: PathAnchor,
-
- // //// contain the type of selection in case there's only one arg
- // //// and it's a path (when it's not None, the user can type ctrl-P
- // //// to select the argument in another panel)
- // /pub arg_selection_type: Option<SelectionType>,
-
pub arg_defs: Vec<ArgDef>,
}
+
impl InvocationParser {
pub fn new(
@@ -96,6 +87,11 @@ impl InvocationParser {
&self.invocation_pattern.name
}
+ pub fn get_unique_arg_def(&self) -> Option<ArgDef> {
+ (self.arg_defs.len() == 1)
+ .then(|| self.arg_defs[0])
+ }
+
pub fn get_unique_arg_anchor(&self) -> PathAnchor {
if self.arg_defs.len() == 1 {
if let ArgDef::Path { anchor, .. } = self.arg_defs[0] {
@@ -104,6 +100,7 @@ impl InvocationParser {
}
PathAnchor::Unspecified
}
+
/// 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