Skip to content

Instantly share code, notes, and snippets.

@andrewmiller1
Created November 10, 2018 06:16
Show Gist options
  • Save andrewmiller1/60db2e82d43e286f6e3b21dcd5c68b4f to your computer and use it in GitHub Desktop.
Save andrewmiller1/60db2e82d43e286f6e3b21dcd5c68b4f to your computer and use it in GitHub Desktop.
Source code #1380
#[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);
}
pub fn build_cli() -> clap::App<'static, 'static> {
app_from_crate!().add_from_yaml(load_yaml!("cli.yml"))
}
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