use clap::{Parser, Subcommand};
use poems::*;
#[derive(Parser)]
#[clap(author, version, about = "poem by example")]
struct Executable {
#[clap(subcommand)]
command: Command,
}
#[derive(Subcommand)]
enum Command {
#[clap(name = "hello")]
#[clap(author, version, about = "Hello world")]
Hello(hello::Options),
#[clap(name = "hello-logger")]
#[clap(author, version, about = "Hello world w/ logger")]
HelloLogger(hello_logger::Options),
#[clap(name = "hello-unix")]
#[clap(author, version, about = "Hello world, unix domain socket")]
HelloUnix(hello_unix::Options),
#[clap(name = "hello-id")]
#[clap(author, version, about = "Hello world, /hello/:id, /hello/:id/:name")]
HelloId(hello_id::Options),
#[clap(name = "nothing")]
#[clap(author, version, about = "Nothing")]
Nothing(nothing::Options),
#[clap(name = "echo")]
#[clap(author, version, about = "Echo request")]
Echo(echo::Options),
#[clap(name = "yaml")]
#[clap(author, version, about = "Echo request (yaml)")]
Yaml(yaml::Options),
#[clap(name = "ser")]
#[clap(author, version, about = "Serve static files")]
Ser(ser::Options),
}
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
Ok(match Executable::parse().command {
Command::Hello(mut options) => {
options.run().await?;
}
Command::HelloLogger(mut options) => {
options.run().await?;
}
Command::HelloId(mut options) => {
options.run().await?;
}
Command::HelloUnix(mut options) => {
options.run().await?;
}
Command::Nothing(mut options) => {
options.run().await?;
}
Command::Echo(mut options) => {
options.run().await?;
}
Command::Yaml(mut options) => {
options.run().await?;
}
Command::Ser(mut options) => {
options.run().await?;
}
})
}