Skip to content

Commit

Permalink
Fix haskell#5488: change default for logging to +nowrap
Browse files Browse the repository at this point in the history
This introduce a +wrap modifier that make Cabal CLI follows the ancient
behavior.
  • Loading branch information
yvan-sraka committed Nov 7, 2023
1 parent 15b5b05 commit 2edc72b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ tests = testGroup "Distribution.Utils.Structured"
, testCase "GenericPackageDescription" $
md5Check (Proxy :: Proxy GenericPackageDescription) 0x6ad1e12c6f88291e9b8c131d239eda70
, testCase "LocalBuildInfo" $
md5Check (Proxy :: Proxy LocalBuildInfo) 0xbc7ac84a9bc43345c812af222c3e5ba0
md5Check (Proxy :: Proxy LocalBuildInfo) 0xca172408aaecfdda2052714e969563cb
#endif
]

Expand Down
4 changes: 2 additions & 2 deletions Cabal/src/Distribution/Simple/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -661,8 +661,8 @@ handleDoesNotExist e =
-- | Wraps text unless the @+nowrap@ verbosity flag is active
wrapTextVerbosity :: Verbosity -> String -> String
wrapTextVerbosity verb
| isVerboseNoWrap verb = withTrailingNewline
| otherwise = withTrailingNewline . wrapText
| isVerboseWrap verb = withTrailingNewline . wrapText
| otherwise = withTrailingNewline

-- | Prepends a timestamp if @+timestamp@ verbosity flag is set
--
Expand Down
21 changes: 17 additions & 4 deletions Cabal/src/Distribution/Verbosity.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ module Distribution.Verbosity
-- * Line wrapping
, verboseNoWrap
, isVerboseNoWrap
, verboseWrap
, isVerboseWrap

-- * Time stamps
, verboseTimestamp
Expand Down Expand Up @@ -229,7 +231,9 @@ parsecVerbosity = parseIntVerbosity <|> parseStringVerbosity
case token of
"callsite" -> return verboseCallSite
"callstack" -> return verboseCallStack
"nowrap" -> return verboseNoWrap
"nowrap" -> return verboseNoWrap -- This is the (new) default, but we
-- choose to not make the CLI break when using the legacy `+nowrap` arg.
"wrap" -> return verboseWrap
"markoutput" -> return verboseMarkOutput
"timestamp" -> return verboseTimestamp
"stderr" -> return verboseStderr
Expand Down Expand Up @@ -257,7 +261,8 @@ showForCabal v

showFlag VCallSite = ["+callsite"]
showFlag VCallStack = ["+callstack"]
showFlag VNoWrap = ["+nowrap"]
-- showFlag VNoWrap = ["+nowrap"]
showFlag VWrap = ["+wrap"]
showFlag VMarkOutput = ["+markoutput"]
showFlag VTimestamp = ["+timestamp"]
showFlag VStderr = ["+stderr"]
Expand Down Expand Up @@ -289,7 +294,11 @@ verboseUnmarkOutput = verboseNoFlag VMarkOutput

-- | Disable line-wrapping for log messages.
verboseNoWrap :: Verbosity -> Verbosity
verboseNoWrap = verboseFlag VNoWrap
verboseNoWrap = verboseNoFlag VWrap

-- | Enable line-wrapping for log messages.
verboseWrap :: Verbosity -> Verbosity
verboseWrap = verboseFlag VWrap

-- | Mark the verbosity as quiet.
verboseQuiet :: Verbosity -> Verbosity
Expand Down Expand Up @@ -348,7 +357,11 @@ isVerboseMarkOutput = isVerboseFlag VMarkOutput

-- | Test if line-wrapping is disabled for log messages.
isVerboseNoWrap :: Verbosity -> Bool
isVerboseNoWrap = isVerboseFlag VNoWrap
isVerboseNoWrap = not . isVerboseWrap

-- | Test if line-wrapping is enabled for log messages.
isVerboseWrap :: Verbosity -> Bool
isVerboseWrap = isVerboseFlag VWrap

-- | Test if we had called 'lessVerbose' on the verbosity.
isVerboseQuiet :: Verbosity -> Bool
Expand Down
4 changes: 3 additions & 1 deletion Cabal/src/Distribution/Verbosity/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ instance Structured VerbosityLevel
data VerbosityFlag
= VCallStack
| VCallSite
| VNoWrap
-- | VNoWrap
| VMarkOutput
| VTimestamp
| -- | @since 3.4.0.0
VStderr
| VNoWarn
| -- | @since 3.12.1.0
VWrap
deriving (Generic, Show, Read, Eq, Ord, Enum, Bounded, Typeable)

instance Binary VerbosityFlag
Expand Down

0 comments on commit 2edc72b

Please sign in to comment.