Better command line documentation

This commit is contained in:
Xiretza 2022-11-13 00:40:18 +01:00
parent 7dc76d328c
commit 1245c823b7
2 changed files with 10 additions and 4 deletions

View file

@ -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<PathBuf>,
#[command(subcommand)]
sub: Option<Subcommand>,
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 {

View file

@ -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<UserId>,
/// An optional homeserver base URL. Will attempt to auto-detect if not
/// specified.
#[arg(long, short = 's')]
homeserver_url: Option<String>,
}