Created
November 10, 2018 06:16
-
-
Save andrewmiller1/60db2e82d43e286f6e3b21dcd5c68b4f to your computer and use it in GitHub Desktop.
Source code #1380
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
#[macro_use] | |
extern crate clap; | |
extern crate clap_generate; | |
use std::env; | |
use clap_generate::Shell; | |
include!("src/cli.rs"); | |
fn main() { | |
let outdir = match env::var_os("OUT_DIR") { | |
None => return, | |
Some(outdir) => outdir, | |
}; | |
let mut app = build_cli(); | |
let name = app.get_name().to_owned(); | |
clap_generate::gen_completions(&mut app, name, Shell::Bash, outdir); | |
} |
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
pub fn build_cli() -> clap::App<'static, 'static> { | |
app_from_crate!().add_from_yaml(load_yaml!("cli.yml")) | |
} |
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
mod cli; | |
fn main() { | |
let m = build_cli().get_matches(); | |
// normal logic continues... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment