From f270bc171fd95707929c978c8ebed2bad70cb498 Mon Sep 17 00:00:00 2001 From: Kevin K Date: Wed, 18 Mar 2015 15:00:15 -0400 Subject: [PATCH] Restructured project to better reflect internal workings --- src/app.rs | 24 +++++++++--------------- src/{ => args}/arg.rs | 0 src/{ => args}/argmatches.rs | 3 +-- src/args/mod.rs | 12 +++++++++--- src/{ => args}/subcommand.rs | 4 ++-- src/lib.rs | 7 +------ 6 files changed, 22 insertions(+), 28 deletions(-) rename src/{ => args}/arg.rs (100%) rename src/{ => args}/argmatches.rs (99%) rename src/{ => args}/subcommand.rs (96%) diff --git a/src/app.rs b/src/app.rs index 3126e581..e190261f 100644 --- a/src/app.rs +++ b/src/app.rs @@ -7,12 +7,7 @@ use std::env; use std::path::Path; use std::vec::IntoIter; -use argmatches::ArgMatches; -use Arg; -use args::OptArg; -use args::FlagArg; -use args::PosArg; -use subcommand::SubCommand; +use args::{ ArgMatches, Arg, OptArg, FlagArg, PosArg, SubCommand }; /// Used to create a representation of the program and all possible command line arguments /// for parsing at runtime. @@ -38,19 +33,18 @@ use subcommand::SubCommand; /// // Your pogram logic starts here... /// ``` pub struct App { - /// The name displayed to the user when showing version and help/usage information - pub name: &'static str, - /// A string of author(s) if desired. Displayed when showing help/usage information - pub author: Option<&'static str>, - /// The version displayed to the user - pub version: Option<&'static str>, - /// A brief explaination of the program that gets displayed to the user when shown help/usage information - pub about: Option<&'static str>, + // The name displayed to the user when showing version and help/usage information + name: &'static str, + // A string of author(s) if desired. Displayed when showing help/usage information + author: Option<&'static str>, + // The version displayed to the user + version: Option<&'static str>, + // A brief explaination of the program that gets displayed to the user when shown help/usage information + about: Option<&'static str>, flags: HashMap<&'static str, FlagArg>, opts: HashMap<&'static str, OptArg>, positionals_idx: BTreeMap, subcommands: HashMap<&'static str, Box>, - // positionals_name: HashMap<&'static str, PosArg>, needs_long_help: bool, needs_long_version: bool, needs_short_help: bool, diff --git a/src/arg.rs b/src/args/arg.rs similarity index 100% rename from src/arg.rs rename to src/args/arg.rs diff --git a/src/argmatches.rs b/src/args/argmatches.rs similarity index 99% rename from src/argmatches.rs rename to src/args/argmatches.rs index f65f1eaf..1e37a37a 100644 --- a/src/argmatches.rs +++ b/src/args/argmatches.rs @@ -1,7 +1,6 @@ use std::collections::HashMap; -use args::{ FlagArg, OptArg, PosArg }; -use subcommand::SubCommand; +use args::{ FlagArg, OptArg, PosArg, SubCommand }; /// Used to get information about the arguments that /// where supplied to the program at runtime. diff --git a/src/args/mod.rs b/src/args/mod.rs index 62af7646..e2ddaecf 100644 --- a/src/args/mod.rs +++ b/src/args/mod.rs @@ -1,7 +1,13 @@ -pub use self::optarg::OptArg; +pub use self::arg::Arg; +pub use self::argmatches::ArgMatches; pub use self::flagarg::FlagArg; +pub use self::optarg::OptArg; pub use self::posarg::PosArg; +pub use self::subcommand::SubCommand; -mod optarg; +mod arg; +mod argmatches; mod flagarg; -mod posarg; \ No newline at end of file +mod optarg; +mod posarg; +mod subcommand; \ No newline at end of file diff --git a/src/subcommand.rs b/src/args/subcommand.rs similarity index 96% rename from src/subcommand.rs rename to src/args/subcommand.rs index 7ef1e94e..c61afb71 100644 --- a/src/subcommand.rs +++ b/src/args/subcommand.rs @@ -1,5 +1,5 @@ -use app::App; -use argmatches::ArgMatches; +use App; +use ArgMatches; /// The abstract representation of a command line subcommand used by the consumer of the library. /// diff --git a/src/lib.rs b/src/lib.rs index c10c949c..a9224151 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -97,16 +97,11 @@ //! test Has test sub-functionality //! ``` -pub use argmatches::ArgMatches; -pub use arg::Arg; +pub use args::{Arg, SubCommand, ArgMatches}; pub use app::App; -pub use subcommand::SubCommand; mod app; -mod argmatches; -mod arg; mod args; -mod subcommand; #[cfg(test)] mod tests {