Better command line documentation
This commit is contained in:
parent
7dc76d328c
commit
1245c823b7
2 changed files with 10 additions and 4 deletions
10
src/main.rs
10
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<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 {
|
||||
|
|
|
@ -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>,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue