44 lines
1 KiB
Rust
44 lines
1 KiB
Rust
use anyhow::Result;
|
|
use clap::{crate_authors, crate_version, AppSettings, Clap};
|
|
|
|
mod posix;
|
|
|
|
#[derive(Clap, Debug)]
|
|
enum Command {
|
|
Create(posix::Create),
|
|
Info(posix::Info),
|
|
Unlink(posix::Unlink),
|
|
Send(posix::Send),
|
|
Recv(posix::Recv),
|
|
}
|
|
|
|
#[derive(Clap, Debug)]
|
|
#[clap(
|
|
version = crate_version!(),
|
|
author = crate_authors!(", "),
|
|
setting = AppSettings::SubcommandRequiredElseHelp,
|
|
global_setting = AppSettings::VersionlessSubcommands,
|
|
global_setting = AppSettings::InferSubcommands,
|
|
)]
|
|
struct Opts {
|
|
/// Produce verbose output
|
|
#[clap(short, long, global = true)]
|
|
verbose: bool,
|
|
#[clap(subcommand)]
|
|
command: Command,
|
|
}
|
|
|
|
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(())
|
|
}
|