Merge pull request #15 from kbknapp/restructure

Restructured project to better reflect internal workings
This commit is contained in:
Kevin K. 2015-03-18 14:03:16 -04:00
commit e711d91998
6 changed files with 22 additions and 28 deletions

View file

@ -7,12 +7,7 @@ use std::env;
use std::path::Path; use std::path::Path;
use std::vec::IntoIter; use std::vec::IntoIter;
use argmatches::ArgMatches; use args::{ ArgMatches, Arg, OptArg, FlagArg, PosArg, SubCommand };
use Arg;
use args::OptArg;
use args::FlagArg;
use args::PosArg;
use subcommand::SubCommand;
/// Used to create a representation of the program and all possible command line arguments /// Used to create a representation of the program and all possible command line arguments
/// for parsing at runtime. /// for parsing at runtime.
@ -38,19 +33,18 @@ use subcommand::SubCommand;
/// // Your pogram logic starts here... /// // Your pogram logic starts here...
/// ``` /// ```
pub struct App { pub struct App {
/// The name displayed to the user when showing version and help/usage information // The name displayed to the user when showing version and help/usage information
pub name: &'static str, name: &'static str,
/// A string of author(s) if desired. Displayed when showing help/usage information // A string of author(s) if desired. Displayed when showing help/usage information
pub author: Option<&'static str>, author: Option<&'static str>,
/// The version displayed to the user // The version displayed to the user
pub version: Option<&'static str>, version: Option<&'static str>,
/// A brief explaination of the program that gets displayed to the user when shown help/usage information // A brief explaination of the program that gets displayed to the user when shown help/usage information
pub about: Option<&'static str>, about: Option<&'static str>,
flags: HashMap<&'static str, FlagArg>, flags: HashMap<&'static str, FlagArg>,
opts: HashMap<&'static str, OptArg>, opts: HashMap<&'static str, OptArg>,
positionals_idx: BTreeMap<u8, PosArg>, positionals_idx: BTreeMap<u8, PosArg>,
subcommands: HashMap<&'static str, Box<App>>, subcommands: HashMap<&'static str, Box<App>>,
// positionals_name: HashMap<&'static str, PosArg>,
needs_long_help: bool, needs_long_help: bool,
needs_long_version: bool, needs_long_version: bool,
needs_short_help: bool, needs_short_help: bool,

View file

@ -1,7 +1,6 @@
use std::collections::HashMap; use std::collections::HashMap;
use args::{ FlagArg, OptArg, PosArg }; use args::{ FlagArg, OptArg, PosArg, SubCommand };
use subcommand::SubCommand;
/// Used to get information about the arguments that /// Used to get information about the arguments that
/// where supplied to the program at runtime. /// where supplied to the program at runtime.

View file

@ -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::flagarg::FlagArg;
pub use self::optarg::OptArg;
pub use self::posarg::PosArg; pub use self::posarg::PosArg;
pub use self::subcommand::SubCommand;
mod optarg; mod arg;
mod argmatches;
mod flagarg; mod flagarg;
mod optarg;
mod posarg; mod posarg;
mod subcommand;

View file

@ -1,5 +1,5 @@
use app::App; use App;
use argmatches::ArgMatches; use ArgMatches;
/// The abstract representation of a command line subcommand used by the consumer of the library. /// The abstract representation of a command line subcommand used by the consumer of the library.
/// ///

View file

@ -97,16 +97,11 @@
//! test Has test sub-functionality //! test Has test sub-functionality
//! ``` //! ```
pub use argmatches::ArgMatches; pub use args::{Arg, SubCommand, ArgMatches};
pub use arg::Arg;
pub use app::App; pub use app::App;
pub use subcommand::SubCommand;
mod app; mod app;
mod argmatches;
mod arg;
mod args; mod args;
mod subcommand;
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {