diff --git a/src/main.rs b/src/main.rs index 2a6f6de..d62b730 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,6 +19,27 @@ struct Cli { action: Action, } +#[derive(clap::Args, Debug, Clone, Eq, PartialEq, PartialOrd, Ord)] +#[group(required = true, multiple = false)] +struct AuthMethodParse { + password: Option, + oauth2_token: Option +} + +enum AuthMethod { + Password(String), + OAuth2Token(String) +} + +impl From for AuthMethod { + fn from (parsed_args: AuthMethodParse) -> AuthMethod { + match parsed_args.password { + None => Self::OAuth2Token(parsed_args.oauth2_token.unwrap()), + Some(password) => Self::Password(password) + } + } +} + #[derive(Parser, Clone, Eq, PartialEq, PartialOrd, Ord)] struct SetupArgs { /// Specify the username of the bot