feat(clap_app!): adds support for arg names with hyphens similar to longs with hyphens

One can now use `("config-file")` style arg names

Closes #869
This commit is contained in:
Kevin K 2017-04-05 00:57:47 -04:00
parent c83a559df1
commit f7a8877978

View file

@ -597,6 +597,13 @@ macro_rules! app_from_crate {
#[macro_export] #[macro_export]
macro_rules! clap_app { macro_rules! clap_app {
(@app ($builder:expr)) => { $builder }; (@app ($builder:expr)) => { $builder };
(@app ($builder:expr) (@arg ($name:expr): $($tail:tt)*) $($tt:tt)*) => {
clap_app!{ @app
($builder.arg(
clap_app!{ @arg ($crate::Arg::with_name($name)) (-) $($tail)* }))
$($tt)*
}
};
(@app ($builder:expr) (@arg $name:ident: $($tail:tt)*) $($tt:tt)*) => { (@app ($builder:expr) (@arg $name:ident: $($tail:tt)*) $($tt:tt)*) => {
clap_app!{ @app clap_app!{ @app
($builder.arg( ($builder.arg(