From 53f5a37f01c0c354a552c50aa87a8edf38f9b9f0 Mon Sep 17 00:00:00 2001
From: gahag <gabriel.s.b@live.com>
Date: Wed, 7 Oct 2020 14:50:44 -0300
Subject: [PATCH] Code review

- Replace bools with enums
- Replace short flag with long flag
---
 src/output.rs | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/output.rs b/src/output.rs
index c42fe68d..1e84e946 100644
--- a/src/output.rs
+++ b/src/output.rs
@@ -10,6 +10,15 @@ use crate::paging::PagingMode;
 #[cfg(feature = "paging")]
 use crate::wrapping::WrappingMode;
 
+
+#[cfg(feature = "paging")]
+#[derive(Debug)]
+enum SingleScreenAction {
+    Quit,
+    Nothing,
+}
+
+
 #[derive(Debug)]
 pub enum OutputType {
     #[cfg(feature = "paging")]
@@ -21,10 +30,9 @@ impl OutputType {
     #[cfg(feature = "paging")]
     pub fn from_mode(paging_mode: PagingMode, wrapping_mode: WrappingMode, pager: Option<&str>) -> Result<Self> {
         use self::PagingMode::*;
-        use self::WrappingMode::*;
         Ok(match paging_mode {
-            Always => OutputType::try_pager(false, wrapping_mode == Character, pager)?,
-            QuitIfOneScreen => OutputType::try_pager(true, wrapping_mode == Character, pager)?,
+            Always => OutputType::try_pager(SingleScreenAction::Nothing, wrapping_mode, pager)?,
+            QuitIfOneScreen => OutputType::try_pager(SingleScreenAction::Quit, wrapping_mode, pager)?,
             _ => OutputType::stdout(),
         })
     }
@@ -32,8 +40,8 @@ impl OutputType {
     /// Try to launch the pager. Fall back to stdout in case of errors.
     #[cfg(feature = "paging")]
     fn try_pager(
-        quit_if_one_screen: bool,
-        line_wrap: bool,
+        single_screen_action: SingleScreenAction,
+        wrapping_mode: WrappingMode,
         pager_from_config: Option<&str>
     ) -> Result<Self> {
         use std::env;
@@ -85,12 +93,12 @@ impl OutputType {
                     let mut p = Command::new(&pager_path);
                     if args.is_empty() || replace_arguments_to_less {
                         p.arg("--RAW-CONTROL-CHARS");
-                        if quit_if_one_screen {
+                        if let SingleScreenAction::Quit = single_screen_action {
                             p.arg("--quit-if-one-screen");
                         }
 
-                        if !line_wrap {
-                            p.arg("-S");
+                        if let WrappingMode::NoWrapping = wrapping_mode {
+                            p.arg("--chop-long-lines");
                         }
 
                         // Passing '--no-init' fixes a bug with '--quit-if-one-screen' in older