diff --git a/src/cli.rs b/src/cli.rs new file mode 100644 index 0000000..03aa4ab --- /dev/null +++ b/src/cli.rs @@ -0,0 +1,35 @@ +use clap::{Parser, Subcommand}; + +#[derive(Parser)] +pub struct Cli { + /// Set a custom username + #[clap(short, long)] + pub username: Option, + + #[clap(subcommand)] + pub command: Option, + + #[arg(short, long, action = clap::ArgAction::Count)] + pub verbose: u8, +} + +#[derive(Subcommand)] +pub enum Commands { + Auth { + api_key: String, + }, + Weblog { + #[arg(short, long)] + yay: u8, + + #[arg(short, long)] + nay: Option, + }, + Status { + #[arg(long)] + message: String, + + /// Does this explain it? + req: String, + }, +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 0654e26..fc1ddb3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,49 +1,18 @@ use anyhow::Context; -use clap::{Parser, Subcommand}; +use clap::Parser; use directories::ProjectDirs; use serde::{Deserialize, Serialize}; use std::fs::read_to_string; +mod cli; +use cli::{Cli, Commands}; + #[derive(Default, Deserialize, Serialize)] struct Config { api_key: Option, username: Option, } -#[derive(Parser)] -struct Cli { - /// Set a custom username - #[clap(short, long)] - username: Option, - - #[clap(subcommand)] - command: Option, - - #[arg(short, long, action = clap::ArgAction::Count)] - verbose: u8, -} - -#[derive(Subcommand)] -enum Commands { - Auth { - api_key: String, - }, - Weblog { - #[arg(short, long)] - yay: u8, - - #[arg(short, long)] - nay: Option, - }, - Status { - #[arg(long)] - message: String, - - /// Does this explain it? - req: String, - }, -} - fn main() -> anyhow::Result<()> { let cli = Cli::parse();