Skip to content

Commit 2edc72b

Browse files
committed
Fix #5488: change default for logging to +nowrap
This introduce a +wrap modifier that make Cabal CLI follows the ancient behavior.
1 parent 15b5b05 commit 2edc72b

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ tests = testGroup "Distribution.Utils.Structured"
2929
, testCase "GenericPackageDescription" $
3030
md5Check (Proxy :: Proxy GenericPackageDescription) 0x6ad1e12c6f88291e9b8c131d239eda70
3131
, testCase "LocalBuildInfo" $
32-
md5Check (Proxy :: Proxy LocalBuildInfo) 0xbc7ac84a9bc43345c812af222c3e5ba0
32+
md5Check (Proxy :: Proxy LocalBuildInfo) 0xca172408aaecfdda2052714e969563cb
3333
#endif
3434
]
3535

Cabal/src/Distribution/Simple/Utils.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,8 +661,8 @@ handleDoesNotExist e =
661661
-- | Wraps text unless the @+nowrap@ verbosity flag is active
662662
wrapTextVerbosity :: Verbosity -> String -> String
663663
wrapTextVerbosity verb
664-
| isVerboseNoWrap verb = withTrailingNewline
665-
| otherwise = withTrailingNewline . wrapText
664+
| isVerboseWrap verb = withTrailingNewline . wrapText
665+
| otherwise = withTrailingNewline
666666

667667
-- | Prepends a timestamp if @+timestamp@ verbosity flag is set
668668
--

Cabal/src/Distribution/Verbosity.hs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ module Distribution.Verbosity
5656
-- * Line wrapping
5757
, verboseNoWrap
5858
, isVerboseNoWrap
59+
, verboseWrap
60+
, isVerboseWrap
5961

6062
-- * Time stamps
6163
, verboseTimestamp
@@ -229,7 +231,9 @@ parsecVerbosity = parseIntVerbosity <|> parseStringVerbosity
229231
case token of
230232
"callsite" -> return verboseCallSite
231233
"callstack" -> return verboseCallStack
232-
"nowrap" -> return verboseNoWrap
234+
"nowrap" -> return verboseNoWrap -- This is the (new) default, but we
235+
-- choose to not make the CLI break when using the legacy `+nowrap` arg.
236+
"wrap" -> return verboseWrap
233237
"markoutput" -> return verboseMarkOutput
234238
"timestamp" -> return verboseTimestamp
235239
"stderr" -> return verboseStderr
@@ -257,7 +261,8 @@ showForCabal v
257261

258262
showFlag VCallSite = ["+callsite"]
259263
showFlag VCallStack = ["+callstack"]
260-
showFlag VNoWrap = ["+nowrap"]
264+
-- showFlag VNoWrap = ["+nowrap"]
265+
showFlag VWrap = ["+wrap"]
261266
showFlag VMarkOutput = ["+markoutput"]
262267
showFlag VTimestamp = ["+timestamp"]
263268
showFlag VStderr = ["+stderr"]
@@ -289,7 +294,11 @@ verboseUnmarkOutput = verboseNoFlag VMarkOutput
289294

290295
-- | Disable line-wrapping for log messages.
291296
verboseNoWrap :: Verbosity -> Verbosity
292-
verboseNoWrap = verboseFlag VNoWrap
297+
verboseNoWrap = verboseNoFlag VWrap
298+
299+
-- | Enable line-wrapping for log messages.
300+
verboseWrap :: Verbosity -> Verbosity
301+
verboseWrap = verboseFlag VWrap
293302

294303
-- | Mark the verbosity as quiet.
295304
verboseQuiet :: Verbosity -> Verbosity
@@ -348,7 +357,11 @@ isVerboseMarkOutput = isVerboseFlag VMarkOutput
348357

349358
-- | Test if line-wrapping is disabled for log messages.
350359
isVerboseNoWrap :: Verbosity -> Bool
351-
isVerboseNoWrap = isVerboseFlag VNoWrap
360+
isVerboseNoWrap = not . isVerboseWrap
361+
362+
-- | Test if line-wrapping is enabled for log messages.
363+
isVerboseWrap :: Verbosity -> Bool
364+
isVerboseWrap = isVerboseFlag VWrap
352365

353366
-- | Test if we had called 'lessVerbose' on the verbosity.
354367
isVerboseQuiet :: Verbosity -> Bool

Cabal/src/Distribution/Verbosity/Internal.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ instance Structured VerbosityLevel
1818
data VerbosityFlag
1919
= VCallStack
2020
| VCallSite
21-
| VNoWrap
21+
-- | VNoWrap
2222
| VMarkOutput
2323
| VTimestamp
2424
| -- | @since 3.4.0.0
2525
VStderr
2626
| VNoWarn
27+
| -- | @since 3.12.1.0
28+
VWrap
2729
deriving (Generic, Show, Read, Eq, Ord, Enum, Bounded, Typeable)
2830

2931
instance Binary VerbosityFlag

0 commit comments

Comments
 (0)