summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2023-03-02 22:25:55 +0800
committersigoden <sigoden@gmail.com>2023-03-02 22:26:32 +0800
commit97af9322e76ff5ec9ca89fc938835ec622731528 (patch)
treedc758d957cd84b86f82424f649cca0643ab617df
parentf66d33e324e5b5894771f7005411e261bb85f0f1 (diff)
downloadaichat-97af9322e76ff5ec9ca89fc938835ec622731528.tar.gz
feat: support list roles with --list-roles
-rw-r--r--src/config.rs4
-rw-r--r--src/main.rs12
2 files changed, 14 insertions, 2 deletions
diff --git a/src/config.rs b/src/config.rs
index 5f76315..0feed64 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -12,7 +12,7 @@ pub struct Config {
/// Used only for debugging
#[serde(default)]
pub dry_run: bool,
- /// Predefined rules
+ /// Predefined roles
#[serde(default)]
pub roles: Vec<Role>,
}
@@ -31,7 +31,7 @@ impl Config {
pub struct Role {
/// Role name
pub name: String,
- /// Prompt text send to ai for setting up a rule
+ /// Prompt text send to ai for setting up a role
pub prompt: String,
/// First sentense will append to prompt
pub first_sentense: String,
diff --git a/src/main.rs b/src/main.rs
index de61a03..8ee2e96 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -49,6 +49,13 @@ fn start() -> Result<()> {
env!("CARGO_PKG_REPOSITORY")
))
.arg(
+ Arg::new("list-roles")
+ .short('L')
+ .long("list-roles")
+ .action(ArgAction::SetTrue)
+ .help("List all roles"),
+ )
+ .arg(
Arg::new("role")
.short('r')
.long("role")
@@ -82,6 +89,11 @@ fn start() -> Result<()> {
text = Some(role.generate(text_));
};
+ if matches.get_flag("list-roles") {
+ config.roles.iter().for_each(|v| println!("{}", v.name));
+ exit(1);
+ }
+
let client = init_client(&config)?;
let runtime = init_runtime()?;
match text {