summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config/mod.rs12
-rw-r--r--src/repl/mod.rs2
2 files changed, 12 insertions, 2 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs
index c98c81d..2eecf62 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -915,7 +915,17 @@ impl Config {
}
pub fn edit_role(&mut self) -> Result<()> {
- if let Some(name) = self.role.as_ref().map(|v| v.name().to_string()) {
+ if let Some(session) = self.session.as_ref() {
+ if let Some(name) = session.role_name().map(|v| v.to_string()) {
+ if session.is_empty() {
+ self.upsert_role(&name)
+ } else {
+ bail!("Cannot perform this operation because you are in a non-empty session")
+ }
+ } else {
+ bail!("No role")
+ }
+ } else if let Some(name) = self.role.as_ref().map(|v| v.name().to_string()) {
self.upsert_role(&name)
} else {
bail!("No role")
diff --git a/src/repl/mod.rs b/src/repl/mod.rs
index 1dd068c..a8b172e 100644
--- a/src/repl/mod.rs
+++ b/src/repl/mod.rs
@@ -53,7 +53,7 @@ lazy_static::lazy_static! {
ReplCommand::new(
".edit role",
"Edit the current role",
- AssertState::TrueFalse(StateFlags::ROLE, StateFlags::SESSION_EMPTY | StateFlags::SESSION),
+ AssertState::TrueFalse(StateFlags::ROLE, StateFlags::SESSION),
),
ReplCommand::new(
".save role",