summaryrefslogtreecommitdiffstats
path: root/src/config
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2023-10-30 10:16:23 +0800
committerGitHub <noreply@github.com>2023-10-30 10:16:23 +0800
commit651516d49a0aa1afe87fe90bd558d162b8877a6e (patch)
tree318bab1b0212601a20cd2750d5f23dcd45df2642 /src/config
parentb276dfedd2d13de9918b9b87a3d543e7b5eca95e (diff)
downloadaichat-651516d49a0aa1afe87fe90bd558d162b8877a6e.tar.gz
feat: show role info with `--role <name> --info` (#175)
Diffstat (limited to 'src/config')
-rw-r--r--src/config/role.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/config/role.rs b/src/config/role.rs
index 23a69df..fee989e 100644
--- a/src/config/role.rs
+++ b/src/config/role.rs
@@ -1,5 +1,6 @@
use super::message::{Message, MessageRole};
+use anyhow::{Context, Result};
use serde::{Deserialize, Serialize};
const TEMP_ROLE_NAME: &str = "temp";
@@ -28,6 +29,12 @@ impl Role {
self.name == TEMP_ROLE_NAME
}
+ pub fn info(&self) -> Result<String> {
+ let output = serde_yaml::to_string(&self)
+ .with_context(|| format!("Unable to show info about role {}", &self.name))?;
+ Ok(output)
+ }
+
pub fn embeded(&self) -> bool {
self.prompt.contains(INPUT_PLACEHOLDER)
}