From 1245c823b73a037763c0c3e29c7d4828c5957ceb Mon Sep 17 00:00:00 2001 From: Xiretza Date: Sun, 13 Nov 2022 00:40:18 +0100 Subject: [PATCH] Better command line documentation --- src/main.rs | 10 ++++++---- src/setup.rs | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index e6a1fd9..dd1fa37 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,15 +26,18 @@ pub struct SessionData { #[derive(clap::Parser)] struct Cli { + /// Override path to the bot's configuration file #[arg(long, short = 'c')] config: Option, #[command(subcommand)] - sub: Option, + sub: Subcommand, } #[derive(clap::Subcommand, Debug)] enum Subcommand { Setup(setup::Setup), + /// Run the bot + Run, } /// Returns the default path to the bot's configuration file. @@ -106,13 +109,12 @@ async fn main() -> Result<()> { let args = Cli::parse(); - #[allow(clippy::single_match_else)] match args.sub { - Some(Subcommand::Setup(setup)) => { + Subcommand::Setup(setup) => { setup::setup(setup).await?; Ok(()) } - None => { + Subcommand::Run => { let config_path = if let Some(config) = args.config { config } else { diff --git a/src/setup.rs b/src/setup.rs index 93caf56..69715bf 100644 --- a/src/setup.rs +++ b/src/setup.rs @@ -7,9 +7,13 @@ use tokio::io::AsyncBufReadExt; use crate::SessionData; +/// Perform first-time setup using password login #[derive(Args, Debug)] pub(crate) struct Setup { + /// The bot's matrix username, e.g. `@mybot:myhomeserver.example` username: Box, + /// An optional homeserver base URL. Will attempt to auto-detect if not + /// specified. #[arg(long, short = 's')] homeserver_url: Option, }