From 3ffebce8bbc530429086302ec4f9a95268c25d07 Mon Sep 17 00:00:00 2001 From: sigoden Date: Fri, 3 Mar 2023 17:53:29 +0800 Subject: refactor: split into separate mods --- src/cli.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/cli.rs (limited to 'src/cli.rs') 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, + /// Input text, if no input text, enter interactive mode + text: Vec, +} + +impl Cli { + pub fn text(&self) -> Option { + let text = self + .text + .iter() + .map(|x| x.trim().to_string()) + .collect::>() + .join(" "); + if text.is_empty() { + return None; + } + Some(text) + } +} -- cgit v1.2.3