From 9347bb866e0b9993d2b8f6cad99ed632ed65ea03 Mon Sep 17 00:00:00 2001 From: sigoden Date: Sat, 7 Sep 2024 15:50:16 +0800 Subject: feat: add role %create-prompt% (#843) --- src/config/mod.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/config/mod.rs') diff --git a/src/config/mod.rs b/src/config/mod.rs index 36a3349..a5b5c5b 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -800,15 +800,17 @@ impl Config { pub fn save_role(&mut self, name: Option<&str>) -> Result<()> { let mut role_name = match &self.role { - Some(role) => match name { - Some(v) => v.to_string(), - None => role.name().to_string(), - }, + Some(role) => { + if role.has_args() { + bail!("Unable to save the role with arguments (whose name contains '#')") + } + match name { + Some(v) => v.to_string(), + None => role.name().to_string(), + } + } None => bail!("No role"), }; - if role_name.contains('#') { - bail!("Unable to save role with arguments") - } if role_name == TEMP_ROLE_NAME { role_name = Text::new("Role name:") .with_validator(|input: &str| { -- cgit v1.2.3