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)]
|
#[derive(clap::Parser)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
|
/// Override path to the bot's configuration file
|
||||||
#[arg(long, short = 'c')]
|
#[arg(long, short = 'c')]
|
||||||
config: Option<PathBuf>,
|
config: Option<PathBuf>,
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
sub: Option<Subcommand>,
|
sub: Subcommand,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(clap::Subcommand, Debug)]
|
#[derive(clap::Subcommand, Debug)]
|
||||||
enum Subcommand {
|
enum Subcommand {
|
||||||
Setup(setup::Setup),
|
Setup(setup::Setup),
|
||||||
|
/// Run the bot
|
||||||
|
Run,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the default path to the bot's configuration file.
|
/// Returns the default path to the bot's configuration file.
|
||||||
|
@ -106,13 +109,12 @@ async fn main() -> Result<()> {
|
||||||
|
|
||||||
let args = Cli::parse();
|
let args = Cli::parse();
|
||||||
|
|
||||||
#[allow(clippy::single_match_else)]
|
|
||||||
match args.sub {
|
match args.sub {
|
||||||
Some(Subcommand::Setup(setup)) => {
|
Subcommand::Setup(setup) => {
|
||||||
setup::setup(setup).await?;
|
setup::setup(setup).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
None => {
|
Subcommand::Run => {
|
||||||
let config_path = if let Some(config) = args.config {
|
let config_path = if let Some(config) = args.config {
|
||||||
config
|
config
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -7,9 +7,13 @@ use tokio::io::AsyncBufReadExt;
|
||||||
|
|
||||||
use crate::SessionData;
|
use crate::SessionData;
|
||||||
|
|
||||||
|
/// Perform first-time setup using password login
|
||||||
#[derive(Args, Debug)]
|
#[derive(Args, Debug)]
|
||||||
pub(crate) struct Setup {
|
pub(crate) struct Setup {
|
||||||
|
/// The bot's matrix username, e.g. `@mybot:myhomeserver.example`
|
||||||
username: Box<UserId>,
|
username: Box<UserId>,
|
||||||
|
/// An optional homeserver base URL. Will attempt to auto-detect if not
|
||||||
|
/// specified.
|
||||||
#[arg(long, short = 's')]
|
#[arg(long, short = 's')]
|
||||||
homeserver_url: Option<String>,
|
homeserver_url: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue