@@ -42,6 +42,7 @@ pub struct Config<'a> {
4242 pub term_width: usize,
4343
4444 /// The width of tab characters.
45+ /// Currently, a value of 0 will cause tabs to be passed through without expanding them.
4546 pub tab_width: usize,
4647
4748 /// Whether or not to simply loop through all input (`cat` mode)
@@ -282,9 +283,14 @@ impl App {
282283 ).arg(
283284 Arg::with_name("tabs")
284285 .long("tabs")
285− .short("t")
286286 .takes_value(true)
287− .value_name("width")
287+ .value_name("tabs")
288+ .validator(
289+ |t| t.parse::<u32>()
290+ .map_err(|_t| "must be a number")
291+ .map(|_t| ()) // Convert to Result<(), &str>
292+ .map_err(|e| e.to_string()) // Convert to Result<(), String>
293+ )
288294 .help("Sets the tab width.")
289295 .long_help("Sets the tab width. Use a width of 0 to pass tabs through \
290296 directly"),
@@ -410,8 +416,9 @@ impl App {
410416 tab_width: self
411417 .matches
412418 .value_of("tabs")
413− .and_then(|w| w.parse().ok())
414− .or_else(|| env::var("BAT_TABS").ok().and_then(|w| w.parse().ok()))
419+ .map(String::from)
420+ .or_else(|| env::var("BAT_TABS").ok())
421+ .and_then(|t| t.parse().ok())
415422 .unwrap_or(
416423 if output_components.plain() && paging_mode == PagingMode::Never {
417424 0