48 lines
972 B
Rust
48 lines
972 B
Rust
use crate::prelude::*;
|
|
use prelude::*;
|
|
|
|
mod prelude {
|
|
pub use clap::{Args, Parser, Subcommand};
|
|
}
|
|
|
|
/// Web application for managing lyrics and live displays
|
|
#[derive(Parser)]
|
|
#[command(version, about, long_about = None)]
|
|
#[command(propagate_version = true)]
|
|
pub struct Cli {
|
|
#[command(subcommand)]
|
|
command: Commands,
|
|
}
|
|
|
|
#[derive(Subcommand)]
|
|
enum Commands {
|
|
/// Run the web application server
|
|
Run(Run),
|
|
}
|
|
|
|
/// Doc comment
|
|
#[derive(Args)]
|
|
struct Run {
|
|
/// Doc comment
|
|
#[arg(short, long, default_value = None)]
|
|
pub watch: bool,
|
|
}
|
|
|
|
impl Run {
|
|
pub async fn run(&self) -> Result<()> {
|
|
let (router, _watchers) = crate::router::router(self.watch).await?;
|
|
crate::webserver::webserver(router, self.watch).await
|
|
}
|
|
}
|
|
|
|
pub fn cli() -> Result<Cli> {
|
|
Ok(Cli::parse())
|
|
}
|
|
|
|
impl Cli {
|
|
pub async fn exec(self) -> Result<()> {
|
|
match self.command {
|
|
Commands::Run(args) => args.run().await,
|
|
}
|
|
}
|
|
}
|