diff options
| author | sigoden <sigoden@gmail.com> | 2023-03-03 17:53:29 +0800 |
|---|---|---|
| committer | sigoden <sigoden@gmail.com> | 2023-03-03 18:27:42 +0800 |
| commit | 3ffebce8bbc530429086302ec4f9a95268c25d07 (patch) | |
| tree | 5c658ec990bb664c441dc1f7abcc418c642cfb36 /src/cli.rs | |
| parent | 2e511c13276b7109e6774263d37eafce8df0a434 (diff) | |
| download | aichat-3ffebce8bbc530429086302ec4f9a95268c25d07.tar.gz | |
refactor: split into separate mods
Diffstat (limited to 'src/cli.rs')
| -rw-r--r-- | src/cli.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/cli.rs b/src/cli.rs new file mode 100644 index 0000000..e1adde7 --- /dev/null +++ b/src/cli.rs @@ -0,0 +1,29 @@ +use clap::Parser; + +#[derive(Parser, Debug)] +#[command(author, version, about, long_about = None)] +pub struct Cli { + /// List all roles + #[clap(short = 'L', long)] + pub list_roles: bool, + /// Specify the role that the AI will play + #[clap(short, long)] + pub role: Option<String>, + /// Input text, if no input text, enter interactive mode + text: Vec<String>, +} + +impl Cli { + pub fn text(&self) -> Option<String> { + let text = self + .text + .iter() + .map(|x| x.trim().to_string()) + .collect::<Vec<String>>() + .join(" "); + if text.is_empty() { + return None; + } + Some(text) + } +} |
