@@ -119,6 +119,24 @@ impl App {
122+ let maybe_term_width = self.matches.value_of("terminal-width").and_then(|w| {
123+ if w.starts_with('+') || w.starts_with('-') {
124+ // Treat argument as a delta to the current terminal width
125+ w.parse().ok().map(|delta: i16| {
126+ let old_width: u16 = Term::stdout().size().1;
127+ let new_width: i32 = i32::from(old_width) + i32::from(delta);
122 Ok(Config {
140 Ok(Config {
123 true_color: is_truecolor_terminal(),
141 true_color: is_truecolor_terminal(),
124 language: self.matches.value_of("language").or_else(|| {
142 language: self.matches.value_of("language").or_else(|| {
@@ -129,11 +147,7 @@ impl App {
131 show_nonprintable: self.matches.is_present("show-all"),
149 show_nonprintable: self.matches.is_present("show-all"),
132− output_wrap: if !self.interactive_output {
150+ output_wrap: if self.interactive_output || maybe_term_width.is_some() {
133− // We don't have the tty width when piping to another program.
134− // There's no point in wrapping when this is the case.
137 match self.matches.value_of("wrap") {
151 match self.matches.value_of("wrap") {
138 Some("character") => OutputWrap::Character,
152 Some("character") => OutputWrap::Character,
139 Some("never") => OutputWrap::None,
153 Some("never") => OutputWrap::None,
@@ -145,6 +159,10 @@ impl App {
163+ // We don't have the tty width when piping to another program.
164+ // There's no point in wrapping when this is the case.
149 colored_output: match self.matches.value_of("color") {
167 colored_output: match self.matches.value_of("color") {
150 Some("always") => true,
168 Some("always") => true,
@@ -152,27 +170,7 @@ impl App {
152 Some("auto") | _ => self.interactive_output,
170 Some("auto") | _ => self.interactive_output,
154 paging_mode,
172 paging_mode,
157− .value_of("terminal-width")
159− if w.starts_with('+') || w.starts_with('-') {
160− // Treat argument as a delta to the current terminal width
161− w.parse().ok().map(|delta: i16| {
162− let old_width: u16 = Term::stdout().size().1;
163− let new_width: i32 = i32::from(old_width) + i32::from(delta);
175− .unwrap_or(Term::stdout().size().1 as usize),
173+ term_width: maybe_term_width.unwrap_or(Term::stdout().size().1 as usize),
176 loop_through: !(self.interactive_output
174 loop_through: !(self.interactive_output
177 || self.matches.value_of("color") == Some("always")
175 || self.matches.value_of("color") == Some("always")
178 || self.matches.value_of("decorations") == Some("always")),
176 || self.matches.value_of("decorations") == Some("always")),