mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2024-12-12 19:18:24 +02:00
0c298f60a6
This commit updates clap to v2.23.0 The update contained a bug fix in clap that results in broken code in ripgrep. ripgrep was relying on the bug, but this commit fixes that issue. The bug centered around not being able to override the auto-generated help message by supplying a flag with a long of `help`. Normally, supplying a flag with a long of `help` means whenever the user passes `--help`, the consuming code (e.g. ripgrep) is responsible for displaying the help message. However, due to the bug in clap this wasn't necessary for ripgrep to do unless the user passed `-h`. With the bug fixed, it meant the user passing `--help` and clap expected ripgrep to display the help, yet ripgrep expected clap to display the help. This has been fixed in this commit of ripgrep. All well now! v2.23.0 also brings the abilty to use `Arg::help` or `Arg::long_help` allowing one to distinguish between `-h` and `--help`. This commit leaves all doc strings in the `lazy_static!` hashmap however only for aesthetic reasons. This means all home rolled handling of `-h`/`--help` has been removed from ripgrep, yet functionality *and* appearances are 100% the same.
28 lines
586 B
Rust
28 lines
586 B
Rust
#[macro_use]
|
|
extern crate clap;
|
|
#[macro_use]
|
|
extern crate lazy_static;
|
|
|
|
use std::env;
|
|
use std::fs;
|
|
|
|
use clap::Shell;
|
|
|
|
#[allow(dead_code)]
|
|
#[path = "src/app.rs"]
|
|
mod app;
|
|
|
|
fn main() {
|
|
let outdir = match env::var_os("OUT_DIR") {
|
|
None => return,
|
|
Some(outdir) => outdir,
|
|
};
|
|
fs::create_dir_all(&outdir).unwrap();
|
|
|
|
let mut app = app::app();
|
|
app.gen_completions("rg", Shell::Bash, &outdir);
|
|
app.gen_completions("rg", Shell::Fish, &outdir);
|
|
app.gen_completions("rg", Shell::Zsh, &outdir);
|
|
app.gen_completions("rg", Shell::PowerShell, &outdir);
|
|
}
|