diff options
| author | sigoden <sigoden@gmail.com> | 2025-01-18 09:28:14 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-18 09:28:14 +0800 |
| commit | 42eedf9e38525c4526f2c3eb2ad67e5bd9b87dbc (patch) | |
| tree | 450577fe9722edfdad35b31b0d3527ab8b8025a0 /src/config/mod.rs | |
| parent | cf3e9691373a776985222e3878b8418b7caf5dcf (diff) | |
| download | aichat-42eedf9e38525c4526f2c3eb2ad67e5bd9b87dbc.tar.gz | |
feat: no longer support role arguments (#1095)
Diffstat (limited to 'src/config/mod.rs')
| -rw-r--r-- | src/config/mod.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index 19bd239..d6e710a 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -885,8 +885,8 @@ impl Config { pub fn retrieve_role(&self, name: &str) -> Result<Role> { let names = Self::list_roles(false); - let mut role = if let Some(role_name) = Role::match_name(&names, name) { - let path = Self::role_file(&role_name); + let mut role = if names.contains(&name.to_string()) { + let path = Self::role_file(name); let content = read_to_string(&path)?; Role::new(name, &content) } else { @@ -942,9 +942,7 @@ impl Config { } pub fn upsert_role(&mut self, name: &str) -> Result<()> { - let names = Self::list_roles(false); - let role_name = Role::match_name(&names, name).unwrap_or_else(|| name.to_string()); - let role_path = Self::role_file(&role_name); + let role_path = Self::role_file(name); ensure_parent_exists(&role_path)?; let editor = self.editor()?; edit_file(&editor, &role_path)?; @@ -1026,7 +1024,7 @@ impl Config { pub fn has_role(name: &str) -> bool { let names = Self::list_roles(true); - Role::match_name(&names, name).is_some() + names.contains(&name.to_string()) } pub fn use_session(&mut self, session_name: Option<&str>) -> Result<()> { |
