mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-05-19 01:30:21 -07:00
argv: support hidden flags
This commit adds support for hidden flags. The purpose of hidden flags is for things that end users likely won't need unless they have a configuration file that disables ripgrep's defaults. These flags will provide a way to re-enable ripgrep's defaults.
This commit is contained in:
parent
706323ad8f
commit
874f0b96a6
3
build.rs
3
build.rs
@ -99,6 +99,9 @@ fn formatted_options() -> io::Result<String> {
|
|||||||
|
|
||||||
let mut formatted = vec![];
|
let mut formatted = vec![];
|
||||||
for arg in args {
|
for arg in args {
|
||||||
|
if arg.hidden {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// ripgrep only has two positional arguments, and probably will only
|
// ripgrep only has two positional arguments, and probably will only
|
||||||
// ever have two positional arguments, so we just hardcode them into
|
// ever have two positional arguments, so we just hardcode them into
|
||||||
// the template.
|
// the template.
|
||||||
|
22
src/app.rs
22
src/app.rs
@ -135,6 +135,18 @@ pub struct RGArg {
|
|||||||
///
|
///
|
||||||
/// This is shown in the `--help` output.
|
/// This is shown in the `--help` output.
|
||||||
pub doc_long: &'static str,
|
pub doc_long: &'static str,
|
||||||
|
/// Whether this flag is hidden or not.
|
||||||
|
///
|
||||||
|
/// This is typically used for uncommon flags that only serve to override
|
||||||
|
/// other flags. For example, --no-ignore is a prominent flag that disables
|
||||||
|
/// ripgrep's gitignore functionality, but --ignore re-enables it. Since
|
||||||
|
/// gitignore support is enabled by default, use of the --ignore flag is
|
||||||
|
/// somewhat niche and relegated to special cases when users make use of
|
||||||
|
/// configuration files to set defaults.
|
||||||
|
///
|
||||||
|
/// Generally, these flags should be documented in the documentation for
|
||||||
|
/// the flag they override.
|
||||||
|
pub hidden: bool,
|
||||||
/// The type of this argument.
|
/// The type of this argument.
|
||||||
pub kind: RGArgKind,
|
pub kind: RGArgKind,
|
||||||
}
|
}
|
||||||
@ -238,6 +250,7 @@ impl RGArg {
|
|||||||
name: name,
|
name: name,
|
||||||
doc_short: "",
|
doc_short: "",
|
||||||
doc_long: "",
|
doc_long: "",
|
||||||
|
hidden: false,
|
||||||
kind: RGArgKind::Positional {
|
kind: RGArgKind::Positional {
|
||||||
value_name: value_name,
|
value_name: value_name,
|
||||||
multiple: false,
|
multiple: false,
|
||||||
@ -261,6 +274,7 @@ impl RGArg {
|
|||||||
name: long_name,
|
name: long_name,
|
||||||
doc_short: "",
|
doc_short: "",
|
||||||
doc_long: "",
|
doc_long: "",
|
||||||
|
hidden: false,
|
||||||
kind: RGArgKind::Switch {
|
kind: RGArgKind::Switch {
|
||||||
long: long_name,
|
long: long_name,
|
||||||
short: None,
|
short: None,
|
||||||
@ -290,6 +304,7 @@ impl RGArg {
|
|||||||
name: long_name,
|
name: long_name,
|
||||||
doc_short: "",
|
doc_short: "",
|
||||||
doc_long: "",
|
doc_long: "",
|
||||||
|
hidden: false,
|
||||||
kind: RGArgKind::Flag {
|
kind: RGArgKind::Flag {
|
||||||
long: long_name,
|
long: long_name,
|
||||||
short: None,
|
short: None,
|
||||||
@ -367,6 +382,13 @@ impl RGArg {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Hide this flag from all documentation.
|
||||||
|
fn hidden(mut self) -> RGArg {
|
||||||
|
self.hidden = true;
|
||||||
|
self.claparg = self.claparg.hidden(true);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Set the possible values for this argument. If this argument is not
|
/// Set the possible values for this argument. If this argument is not
|
||||||
/// a flag, then this panics.
|
/// a flag, then this panics.
|
||||||
///
|
///
|
||||||
|
Loading…
x
Reference in New Issue
Block a user