|
|
@ -8,7 +8,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
|
|
|
AppSettings::ColorNever
|
|
|
|
AppSettings::ColorNever
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let app = ClapApp::new(crate_name!())
|
|
|
|
let mut app = ClapApp::new(crate_name!())
|
|
|
|
.version(crate_version!())
|
|
|
|
.version(crate_version!())
|
|
|
|
.global_setting(clap_color_setting)
|
|
|
|
.global_setting(clap_color_setting)
|
|
|
|
.global_setting(AppSettings::DeriveDisplayOrder)
|
|
|
|
.global_setting(AppSettings::DeriveDisplayOrder)
|
|
|
@ -44,7 +44,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
|
|
|
.long_help(
|
|
|
|
.long_help(
|
|
|
|
"Show non-printable characters like space, tab or newline. \
|
|
|
|
"Show non-printable characters like space, tab or newline. \
|
|
|
|
This option can also be used to print binary files. \
|
|
|
|
This option can also be used to print binary files. \
|
|
|
|
Use '--tabs' to control the width of the tab-placeholders."
|
|
|
|
Use '--tabs' to control the width of the tab-placeholders.",
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
.arg(
|
|
|
@ -90,7 +90,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
|
|
|
'--highlight-line 40' highlights line 40\n \
|
|
|
|
'--highlight-line 40' highlights line 40\n \
|
|
|
|
'--highlight-line 30:40' highlights lines 30 to 40\n \
|
|
|
|
'--highlight-line 30:40' highlights lines 30 to 40\n \
|
|
|
|
'--highlight-line :40' highlights lines 1 to 40\n \
|
|
|
|
'--highlight-line :40' highlights lines 1 to 40\n \
|
|
|
|
'--highlight-line 40:' highlights lines 40 to the end of the file"
|
|
|
|
'--highlight-line 40:' highlights lines 40 to the end of the file",
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
.arg(
|
|
|
@ -101,59 +101,67 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
|
|
|
.multiple(true)
|
|
|
|
.multiple(true)
|
|
|
|
.value_name("name")
|
|
|
|
.value_name("name")
|
|
|
|
.help("Specify the name to display for a file.")
|
|
|
|
.help("Specify the name to display for a file.")
|
|
|
|
.long_help("Specify the name to display for a file. Useful when piping \
|
|
|
|
|
|
|
|
data to bat from STDIN when bat does not otherwise know \
|
|
|
|
|
|
|
|
the filename."),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.arg(
|
|
|
|
|
|
|
|
Arg::with_name("diff")
|
|
|
|
|
|
|
|
.long("diff")
|
|
|
|
|
|
|
|
.short("d")
|
|
|
|
|
|
|
|
.help("Only show lines that have been added/removed/modified.")
|
|
|
|
|
|
|
|
.long_help(
|
|
|
|
.long_help(
|
|
|
|
"Only show lines that have been added/removed/modified with respect \
|
|
|
|
"Specify the name to display for a file. Useful when piping \
|
|
|
|
to the Git index. Use --diff-context=N to control how much context you want to see.",
|
|
|
|
data to bat from STDIN when bat does not otherwise know \
|
|
|
|
|
|
|
|
the filename.",
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
.arg(
|
|
|
|
|
|
|
|
Arg::with_name("diff-context")
|
|
|
|
#[cfg(feature = "git")]
|
|
|
|
.long("diff-context")
|
|
|
|
{
|
|
|
|
.overrides_with("diff-context")
|
|
|
|
app = app
|
|
|
|
.takes_value(true)
|
|
|
|
.arg(
|
|
|
|
.value_name("N")
|
|
|
|
Arg::with_name("diff")
|
|
|
|
.validator(
|
|
|
|
.long("diff")
|
|
|
|
|n| {
|
|
|
|
.short("d")
|
|
|
|
n.parse::<usize>()
|
|
|
|
.help("Only show lines that have been added/removed/modified.")
|
|
|
|
.map_err(|_| "must be a number")
|
|
|
|
.long_help(
|
|
|
|
.map(|_| ()) // Convert to Result<(), &str>
|
|
|
|
"Only show lines that have been added/removed/modified with respect \
|
|
|
|
.map_err(|e| e.to_string())
|
|
|
|
to the Git index. Use --diff-context=N to control how much context you want to see.",
|
|
|
|
}, // Convert to Result<(), String>
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.hidden_short_help(true)
|
|
|
|
.arg(
|
|
|
|
.long_help(
|
|
|
|
Arg::with_name("diff-context")
|
|
|
|
"Include N lines of context around added/removed/modified lines when using '--diff'.",
|
|
|
|
.long("diff-context")
|
|
|
|
),
|
|
|
|
.overrides_with("diff-context")
|
|
|
|
)
|
|
|
|
.takes_value(true)
|
|
|
|
.arg(
|
|
|
|
.value_name("N")
|
|
|
|
Arg::with_name("tabs")
|
|
|
|
.validator(
|
|
|
|
.long("tabs")
|
|
|
|
|n| {
|
|
|
|
.overrides_with("tabs")
|
|
|
|
n.parse::<usize>()
|
|
|
|
.takes_value(true)
|
|
|
|
.map_err(|_| "must be a number")
|
|
|
|
.value_name("T")
|
|
|
|
.map(|_| ()) // Convert to Result<(), &str>
|
|
|
|
.validator(
|
|
|
|
.map_err(|e| e.to_string())
|
|
|
|
|t| {
|
|
|
|
}, // Convert to Result<(), String>
|
|
|
|
t.parse::<u32>()
|
|
|
|
)
|
|
|
|
.map_err(|_t| "must be a number")
|
|
|
|
.hidden_short_help(true)
|
|
|
|
.map(|_t| ()) // Convert to Result<(), &str>
|
|
|
|
.long_help(
|
|
|
|
.map_err(|e| e.to_string())
|
|
|
|
"Include N lines of context around added/removed/modified lines when using '--diff'.",
|
|
|
|
}, // Convert to Result<(), String>
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.help("Set the tab width to T spaces.")
|
|
|
|
}
|
|
|
|
.long_help(
|
|
|
|
|
|
|
|
"Set the tab width to T spaces. Use a width of 0 to pass tabs through \
|
|
|
|
app = app.arg(
|
|
|
|
|
|
|
|
Arg::with_name("tabs")
|
|
|
|
|
|
|
|
.long("tabs")
|
|
|
|
|
|
|
|
.overrides_with("tabs")
|
|
|
|
|
|
|
|
.takes_value(true)
|
|
|
|
|
|
|
|
.value_name("T")
|
|
|
|
|
|
|
|
.validator(
|
|
|
|
|
|
|
|
|t| {
|
|
|
|
|
|
|
|
t.parse::<u32>()
|
|
|
|
|
|
|
|
.map_err(|_t| "must be a number")
|
|
|
|
|
|
|
|
.map(|_t| ()) // Convert to Result<(), &str>
|
|
|
|
|
|
|
|
.map_err(|e| e.to_string())
|
|
|
|
|
|
|
|
}, // Convert to Result<(), String>
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.help("Set the tab width to T spaces.")
|
|
|
|
|
|
|
|
.long_help(
|
|
|
|
|
|
|
|
"Set the tab width to T spaces. Use a width of 0 to pass tabs through \
|
|
|
|
directly",
|
|
|
|
directly",
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("wrap")
|
|
|
|
Arg::with_name("wrap")
|
|
|
|
.long("wrap")
|
|
|
|
.long("wrap")
|
|
|
@ -334,7 +342,9 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
|
|
|
|
.validator(|val| {
|
|
|
|
.validator(|val| {
|
|
|
|
let mut invalid_vals = val.split(',').filter(|style| {
|
|
|
|
let mut invalid_vals = val.split(',').filter(|style| {
|
|
|
|
!&[
|
|
|
|
!&[
|
|
|
|
"auto", "full", "plain", "changes", "header", "grid", "numbers", "snip"
|
|
|
|
"auto", "full", "plain", "header", "grid", "numbers", "snip",
|
|
|
|
|
|
|
|
#[cfg(feature = "git")]
|
|
|
|
|
|
|
|
"changes",
|
|
|
|
]
|
|
|
|
]
|
|
|
|
.contains(style)
|
|
|
|
.contains(style)
|
|
|
|
});
|
|
|
|
});
|
|
|
|