Move clap options and types into main

This commit is contained in:
finga 2021-06-20 17:50:24 +02:00
parent 487d5a9971
commit bcefd6241b
2 changed files with 26 additions and 30 deletions

View file

@ -1,27 +0,0 @@
use crate::{create::Create, info::Info, recv::Recv, send::Send, unlink::Unlink};
use clap::{crate_authors, crate_version, AppSettings, Clap};
#[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),
}

View file

@ -1,7 +1,7 @@
use crate::{create::Create, info::Info, recv::Recv, send::Send, unlink::Unlink};
use anyhow::Result;
use clap::Clap;
use clap::{crate_authors, crate_version, AppSettings, Clap};
mod cli;
mod create;
mod info;
mod recv;
@ -9,7 +9,30 @@ mod send;
mod unlink;
mod utils;
use cli::{Command, Opts};
#[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();