Skip to content

Commit

Permalink
Add example for multicall completion generation
Browse files Browse the repository at this point in the history
  • Loading branch information
fishface60 committed Nov 19, 2021
1 parent 2fe7a89 commit 5ec71cc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clap_generate/Cargo.toml
Expand Up @@ -36,7 +36,7 @@ clap = { path = "../", version = "=3.0.0-beta.5", default-features = false, feat
[dev-dependencies]
pretty_assertions = "0.7"
version-sync = "0.9"
clap = { path = "../", version = "=3.0.0-beta.5", default-features = false, features = ["std", "derive"] }
clap = { path = "../", version = "=3.0.0-beta.5", default-features = false, features = ["std", "derive", "unstable-multicall"] }

[features]
default = []
Expand Down
18 changes: 18 additions & 0 deletions clap_generate/examples/multicall.rs
@@ -0,0 +1,18 @@
use clap::{App, AppSettings};
use clap_generate::{generate, generators::Bash};
use std::io;

fn main() {
let mut app = App::new(env!("CARGO_CRATE_NAME"))
.setting(AppSettings::Multicall)
.subcommand(
App::new("test")
.subcommand(App::new("config"))
.subcommand(App::new("generate-completions")),
)
.subcommand(App::new("hello"));
for applet in app.get_subcommands_mut() {
let name = applet.get_name().to_owned();
generate(Bash, applet, &name, &mut io::stdout());
}
}

0 comments on commit 5ec71cc

Please sign in to comment.