Created
September 19, 2019 15:41
-
-
Save CreepySkeleton/297b217066d98d03500c1f42613b0d1e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(prelude_import)] | |
#[prelude_import] | |
use std::prelude::v1::*; | |
#[macro_use] | |
extern crate std; | |
use structopt::StructOpt; | |
pub struct A { | |
#[structopt(flatten)] | |
pub b: B, | |
} | |
#[allow(unused_variables)] | |
impl ::structopt::StructOpt for A { | |
fn clap<'a, 'b>() -> ::structopt::clap::App<'a, 'b> { | |
let app = ::structopt::clap::App::new("probe").version("0.2.0"); | |
Self::augment_clap(app) | |
} | |
fn from_clap(matches: &::structopt::clap::ArgMatches) -> Self { | |
A { | |
b: ::structopt::StructOpt::from_clap(matches), | |
} | |
} | |
} | |
#[allow(dead_code, unreachable_code)] | |
#[doc(hidden)] | |
impl A { | |
pub fn augment_clap<'a, 'b>( | |
app: ::structopt::clap::App<'a, 'b>, | |
) -> ::structopt::clap::App<'a, 'b> { | |
{ | |
let app = <B>::augment_clap(app); | |
let app = if <B>::is_subcommand() { | |
app.setting(::structopt::clap::AppSettings::SubcommandRequiredElseHelp) | |
} else { | |
app | |
}; | |
app | |
} | |
} | |
pub fn is_subcommand() -> bool { | |
false | |
} | |
} | |
pub struct B {} | |
#[allow(unused_variables)] | |
impl ::structopt::StructOpt for B { | |
fn clap<'a, 'b>() -> ::structopt::clap::App<'a, 'b> { | |
let app = ::structopt::clap::App::new("probe").version("0.2.0"); | |
Self::augment_clap(app) | |
} | |
fn from_clap(matches: &::structopt::clap::ArgMatches) -> Self { | |
B {} | |
} | |
} | |
#[allow(dead_code, unreachable_code)] | |
#[doc(hidden)] | |
impl B { | |
pub fn augment_clap<'a, 'b>( | |
app: ::structopt::clap::App<'a, 'b>, | |
) -> ::structopt::clap::App<'a, 'b> { | |
{ | |
app | |
} | |
} | |
pub fn is_subcommand() -> bool { | |
false | |
} | |
} | |
fn main() {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment