@@ -8,7 +8,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
88 AppSettings::ColorNever
99 };
1010
11− let app = ClapApp::new(crate_name!())
11+ let mut app = ClapApp::new(crate_name!())
1212 .version(crate_version!())
1313 .global_setting(clap_color_setting)
1414 .global_setting(AppSettings::DeriveDisplayOrder)
@@ -44,7 +44,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
4444 .long_help(
4545 "Show non-printable characters like space, tab or newline. \
4646 This option can also be used to print binary files. \
47− Use '--tabs' to control the width of the tab-placeholders."
47+ Use '--tabs' to control the width of the tab-placeholders.",
4848 ),
4949 )
5050 .arg(
@@ -90,7 +90,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
9090 '--highlight-line 40' highlights line 40\n \
9191 '--highlight-line 30:40' highlights lines 30 to 40\n \
9292 '--highlight-line :40' highlights lines 1 to 40\n \
93− '--highlight-line 40:' highlights lines 40 to the end of the file"
93+ '--highlight-line 40:' highlights lines 40 to the end of the file",
9494 ),
9595 )
9696 .arg(
@@ -101,59 +101,67 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
101101 .multiple(true)
102102 .value_name("name")
103103 .help("Specify the name to display for a file.")
104− .long_help("Specify the name to display for a file. Useful when piping \
105− data to bat from STDIN when bat does not otherwise know \
106− the filename."),
107− )
108− .arg(
109− Arg::with_name("diff")
110− .long("diff")
111− .short("d")
112− .help("Only show lines that have been added/removed/modified.")
113104 .long_help(
114− "Only show lines that have been added/removed/modified with respect \
115− to the Git index. Use --diff-context=N to control how much context you want to see.",
105+ "Specify the name to display for a file. Useful when piping \
106+ data to bat from STDIN when bat does not otherwise know \
107+ the filename.",
116108 ),
117− )
118− .arg(
119− Arg::with_name("diff-context")
120− .long("diff-context")
121− .overrides_with("diff-context")
122− .takes_value(true)
123− .value_name("N")
124− .validator(
125− |n| {
126− n.parse::<usize>()
127− .map_err(|_| "must be a number")
128− .map(|_| ()) // Convert to Result<(), &str>
129− .map_err(|e| e.to_string())
130− }, // Convert to Result<(), String>
109+ );
110+
111+ #[cfg(feature = "git")]
112+ {
113+ app = app
114+ .arg(
115+ Arg::with_name("diff")
116+ .long("diff")
117+ .short("d")
118+ .help("Only show lines that have been added/removed/modified.")
119+ .long_help(
120+ "Only show lines that have been added/removed/modified with respect \
121+ to the Git index. Use --diff-context=N to control how much context you want to see.",
122+ ),
131123 )
132− .hidden_short_help(true)
133− .long_help(
134− "Include N lines of context around added/removed/modified lines when using '--diff'.",
135− ),
136− )
137− .arg(
138− Arg::with_name("tabs")
139− .long("tabs")
140− .overrides_with("tabs")
141− .takes_value(true)
142− .value_name("T")
143− .validator(
144− |t| {
145− t.parse::<u32>()
146− .map_err(|_t| "must be a number")
147− .map(|_t| ()) // Convert to Result<(), &str>
148− .map_err(|e| e.to_string())
149− }, // Convert to Result<(), String>
124+ .arg(
125+ Arg::with_name("diff-context")
126+ .long("diff-context")
127+ .overrides_with("diff-context")
128+ .takes_value(true)
129+ .value_name("N")
130+ .validator(
131+ |n| {
132+ n.parse::<usize>()
133+ .map_err(|_| "must be a number")
134+ .map(|_| ()) // Convert to Result<(), &str>
135+ .map_err(|e| e.to_string())
136+ }, // Convert to Result<(), String>
137+ )
138+ .hidden_short_help(true)
139+ .long_help(
140+ "Include N lines of context around added/removed/modified lines when using '--diff'.",
141+ ),
150142 )
151− .help("Set the tab width to T spaces.")
152− .long_help(
153− "Set the tab width to T spaces. Use a width of 0 to pass tabs through \
143+ }
144+
145+ app = app.arg(
146+ Arg::with_name("tabs")
147+ .long("tabs")
148+ .overrides_with("tabs")
149+ .takes_value(true)
150+ .value_name("T")
151+ .validator(
152+ |t| {
153+ t.parse::<u32>()
154+ .map_err(|_t| "must be a number")
155+ .map(|_t| ()) // Convert to Result<(), &str>
156+ .map_err(|e| e.to_string())
157+ }, // Convert to Result<(), String>
158+ )
159+ .help("Set the tab width to T spaces.")
160+ .long_help(
161+ "Set the tab width to T spaces. Use a width of 0 to pass tabs through \
154162 directly",
155− ),
156− )
163+ ),
164+ )
157165 .arg(
158166 Arg::with_name("wrap")
159167 .long("wrap")
@@ -334,7 +342,9 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
334342 .validator(|val| {
335343 let mut invalid_vals = val.split(',').filter(|style| {
336344 !&[
337− "auto", "full", "plain", "changes", "header", "grid", "numbers", "snip"
345+ "auto", "full", "plain", "header", "grid", "numbers", "snip",
346+ #[cfg(feature = "git")]
347+ "changes",
338348 ]
339349 .contains(style)
340350 });