mqrs/src/main.rs

49 lines
1.1 KiB
Rust

use crate::{create::Create, info::Info, recv::Recv, send::Send, unlink::Unlink};
use anyhow::Result;
use clap::{crate_authors, crate_version, AppSettings, Clap};
mod create;
mod info;
mod recv;
mod send;
mod unlink;
#[derive(Clap, Debug)]
#[clap(
version = crate_version!(),
author = crate_authors!(", "),
setting = AppSettings::SubcommandRequiredElseHelp,
global_setting = AppSettings::VersionlessSubcommands,
global_setting = AppSettings::InferSubcommands,
)]
pub struct Opts {
/// Produce verbose output
#[clap(short, long, global = true)]
pub verbose: bool,
#[clap(subcommand)]
pub command: Command,
}
#[derive(Clap, Debug)]
pub enum Command {
Create(Create),
Info(Info),
Unlink(Unlink),
Send(Send),
Recv(Recv),
}
fn main() -> Result<()> {
let opts: Opts = Opts::parse();
match opts.command {
Command::Create(c) => c.run(opts.verbose)?,
Command::Info(i) => i.run()?,
Command::Unlink(u) => u.run(opts.verbose)?,
Command::Send(s) => s.run(opts.verbose)?,
Command::Recv(r) => r.run(opts.verbose)?,
}
Ok(())
}