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 3, 2023
1 parent 1157461 commit 62df668
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 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) 0xe5f8e4856403a42f1eb93680e90097fb
#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
11 changes: 11 additions & 0 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 @@ -258,6 +260,7 @@ showForCabal v
showFlag VCallSite = ["+callsite"]
showFlag VCallStack = ["+callstack"]
showFlag VNoWrap = ["+nowrap"]
showFlag VWrap = ["+wrap"]
showFlag VMarkOutput = ["+markoutput"]
showFlag VTimestamp = ["+timestamp"]
showFlag VStderr = ["+stderr"]
Expand Down Expand Up @@ -291,6 +294,10 @@ verboseUnmarkOutput = verboseNoFlag VMarkOutput
verboseNoWrap :: Verbosity -> Verbosity
verboseNoWrap = verboseFlag VNoWrap

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

-- | Mark the verbosity as quiet.
verboseQuiet :: Verbosity -> Verbosity
verboseQuiet v = v{vQuiet = True}
Expand Down Expand Up @@ -350,6 +357,10 @@ isVerboseMarkOutput = isVerboseFlag VMarkOutput
isVerboseNoWrap :: Verbosity -> Bool
isVerboseNoWrap = isVerboseFlag VNoWrap

-- | 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
isVerboseQuiet = vQuiet
Expand Down
2 changes: 2 additions & 0 deletions Cabal/src/Distribution/Verbosity/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ data VerbosityFlag
| -- | @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 62df668

Please sign in to comment.