mirror of
https://github.com/clap-rs/clap
synced 2024-12-15 07:12:32 +00:00
88a335ff97
`clap_generate` originally intended to be "generate anything". With `fig`, we already broke one part out. With #3174's man support, we are also looking at keeping it separate: - More freedom to iterate on the API - Uniqueness (and potential weight) of its dependencies - man generation is normally more for distribution while completions are a mix of being distributed with the app or the app generating the completions (which will be exacerbated if we move most completion parsing logic to be in Rust) So `clap_generate` is having a lot more limited of a role than the original name conveys. I worry the generic name will be a hindrance to people discovering and using it (yes, documentation can help but there are limits). I hesitated because we are on the verge of releasing 3.0. However, doing it even later will be even more disruptive because more people will be using it (crates.io lists ~70 people using `clap_generate`). To ease things, we are still releasing `clap_generate` as a wrapper around `clap_complete`.
23 lines
756 B
Rust
23 lines
756 B
Rust
#![allow(deprecated)]
|
|
|
|
use clap::{App, Arg};
|
|
use clap_generate::{generate, generators::*};
|
|
use std::io;
|
|
|
|
#[test]
|
|
fn generate_completions() {
|
|
let mut app = App::new("test_app")
|
|
.arg(Arg::new("config").short('c').global(true))
|
|
.arg(Arg::new("v").short('v').conflicts_with("config"))
|
|
.subcommand(
|
|
App::new("test")
|
|
.about("Subcommand")
|
|
.arg(Arg::new("debug").short('d')),
|
|
);
|
|
|
|
generate(Bash, &mut app, "test_app", &mut io::sink());
|
|
generate(Fish, &mut app, "test_app", &mut io::sink());
|
|
generate(PowerShell, &mut app, "test_app", &mut io::sink());
|
|
generate(Elvish, &mut app, "test_app", &mut io::sink());
|
|
generate(Zsh, &mut app, "test_app", &mut io::sink());
|
|
}
|