diff --git a/README.md b/README.md index 2b3ee6f..5b5a80a 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ the gophersphere. -o, --tor Use local Tor proxy to open all pages -S, -O Disable TLS or Tor + -w, --wrap COLUMN Wrap long lines in "text" views at COLUMN. -m, --media PROGRAM Use to open media files. Default: mpv -M, --no-media Just download media files, don't download diff --git a/doc/phetch.1 b/doc/phetch.1 index f5accb0..e4eefb3 100644 --- a/doc/phetch.1 +++ b/doc/phetch.1 @@ -72,6 +72,12 @@ Tor default of 127.0.0.1:9050. Disable Tor. .P .RE +\fB-w\fR, \fB--wrap\fR \fICOLUMN\fR +.RS 4 +Wrap long lines in Gopher "text" views at \fICOLUMN\fR. +Default: 0 (off) +.P +.RE \fB-m\fR, \fB--media\fR \fIPATH\fR .RS 4 Use program at \fIPATH\fR to open media files (movies and sounds). diff --git a/doc/phetch.1.md b/doc/phetch.1.md index 99a32e5..c5b9202 100644 --- a/doc/phetch.1.md +++ b/doc/phetch.1.md @@ -49,6 +49,10 @@ If no URL is given, however, *phetch* will launch and open its default *-O*, *--no-tor* Disable Tor. +*-w*, *--wrap* _COLUMN_ + Wrap long lines in Gopher "text" views at _COLUMN_. + Default: 0 (off) + *-m*, *--media* _PATH_ Use program at _PATH_ to open media files (movies and sounds). Default: mpv diff --git a/src/args.rs b/src/args.rs index 752310c..5e52493 100644 --- a/src/args.rs +++ b/src/args.rs @@ -163,6 +163,17 @@ pub fn parse>(args: &[T]) -> Result { set_notor = true; cfg.tor = false; } + "-w" | "--wrap" | "-wrap" => { + if let Some(column) = iter.next() { + if let Ok(col) = column.as_ref().parse() { + cfg.wrap = col; + } else { + return Err(ArgError::new("--wrap expects a COLUMN arg")); + } + } else { + return Err(ArgError::new("--wrap expects a COLUMN arg")); + } + } "-m" | "--media" | "-media" => { if set_nomedia { return Err(ArgError::new("can't set both --media and --no-media")); diff --git a/src/config.rs b/src/config.rs index 1222251..e560437 100644 --- a/src/config.rs +++ b/src/config.rs @@ -72,6 +72,8 @@ pub struct Config { pub encoding: Encoding, /// UI mode. Can't be set in conf file. pub mode: ui::Mode, + /// Column to wrap lines. 0 = off + pub wrap: usize, } impl Default for Config { @@ -85,6 +87,7 @@ impl Default for Config { media: Some(DEFAULT_MEDIA_PLAYER.into()), encoding: Encoding::default(), mode: ui::Mode::default(), + wrap: 0, } } } @@ -151,6 +154,16 @@ fn parse(text: &str) -> Result { "tls" => cfg.tls = to_bool(val)?, "tor" => cfg.tor = to_bool(val)?, "wide" => cfg.wide = to_bool(val)?, + "wrap" => { + if let Ok(num) = val.parse() { + cfg.wrap = num; + } else { + return Err(error!( + "`wrap` expects a number value on line {}: {}", + linenum, val + )); + } + } "media" => { cfg.media = match val.to_lowercase().as_ref() { "false" | "none" => None, diff --git a/src/main.rs b/src/main.rs index 7eaf98e..a88d376 100644 --- a/src/main.rs +++ b/src/main.rs @@ -77,6 +77,7 @@ Options: -o, --tor Use local Tor proxy to open all pages -S, -O Disable TLS or Tor + -w, --wrap COLUMN Wrap long lines in \"text\" views at COLUMN. -m, --media PROGRAM Use to open media files. Default: mpv -M, --no-media Just download media files, don't download