mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-06 13:57:54 +00:00
add x alias for edit -regex
This commit is contained in:
parent
0a3b15eb45
commit
516eaa5292
3 changed files with 29 additions and 5 deletions
|
|
@ -1,12 +1,12 @@
|
|||
use std::{
|
||||
collections::HashSet,
|
||||
collections::{HashMap, HashSet},
|
||||
fmt::{Debug, Display},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use smol_str::SmolStr;
|
||||
|
||||
use crate::{flag::Flag, token::Token};
|
||||
use crate::{flag::Flag, parameter::ParameterValue, token::Token};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Command {
|
||||
|
|
@ -18,6 +18,7 @@ pub struct Command {
|
|||
pub show_in_suggestions: bool,
|
||||
pub parse_flags_before: usize,
|
||||
pub hidden_flags: HashSet<SmolStr>,
|
||||
pub flag_values: HashMap<SmolStr, Option<ParameterValue>>,
|
||||
pub original: Option<Arc<Command>>,
|
||||
}
|
||||
|
||||
|
|
@ -43,6 +44,7 @@ impl Command {
|
|||
parse_flags_before,
|
||||
tokens,
|
||||
hidden_flags: HashSet::new(),
|
||||
flag_values: HashMap::new(),
|
||||
original: None,
|
||||
}
|
||||
}
|
||||
|
|
@ -73,6 +75,15 @@ impl Command {
|
|||
self.flags.insert(flag);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn flag_value(
|
||||
mut self,
|
||||
flag_name: impl Into<SmolStr>,
|
||||
value: impl Into<Option<ParameterValue>>,
|
||||
) -> Self {
|
||||
self.flag_values.insert(flag_name.into(), value.into());
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Command {
|
||||
|
|
|
|||
|
|
@ -350,6 +350,11 @@ pub fn parse_command(
|
|||
.expect("oom");
|
||||
return Err(error);
|
||||
}
|
||||
|
||||
for (name, value) in &full_cmd.flag_values {
|
||||
flags.insert(name.to_string(), value.clone());
|
||||
}
|
||||
|
||||
println!("{} {flags:?} {params:?}", command.cb);
|
||||
return Ok(ParsedCommand {
|
||||
command_def: command,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue