From bcefd6241b9e730f46f56690a0cc25589279fdbc Mon Sep 17 00:00:00 2001 From: finga Date: Sun, 20 Jun 2021 17:50:24 +0200 Subject: [PATCH] Move clap options and types into main --- src/cli.rs | 27 --------------------------- src/main.rs | 29 ++++++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 30 deletions(-) delete mode 100644 src/cli.rs diff --git a/src/cli.rs b/src/cli.rs deleted file mode 100644 index 4148233..0000000 --- a/src/cli.rs +++ /dev/null @@ -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), -} diff --git a/src/main.rs b/src/main.rs index d85fa83..8cf86b7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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();