Skip to content

Commit

Permalink
Merge branch 'master' into wip/romes/9448
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Dec 6, 2023
2 parents 8183a73 + d9af0dc commit 00bc7de
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
10 changes: 5 additions & 5 deletions cabal-install/src/Distribution/Client/Init/FileCreators.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ writeProject (ProjectSettings opts pkgDesc libTarget exeTarget testTarget)
message opts T.Error "no package name given, so no .cabal file can be generated\n"
| otherwise = do
-- clear prompt history a bit"
message opts T.Log $
message opts T.Info $
"Using cabal specification: "
++ showCabalSpecVersion (_optCabalSpec opts)

Expand Down Expand Up @@ -269,7 +269,7 @@ writeFileSafe opts fileName content = do

go exists

message opts T.Log $ show action ++ " file " ++ fileName ++ "..."
message opts T.Info $ show action ++ " file " ++ fileName ++ "..."
return $ action == Existing
where
doOverwrite = _optOverwrite opts
Expand All @@ -279,7 +279,7 @@ writeFileSafe opts fileName content = do
writeFile fileName content
| exists && doOverwrite = do
newName <- findNewPath fileName
message opts T.Log $
message opts T.Info $
concat
[ fileName
, " already exists. Backing up old version in "
Expand All @@ -302,7 +302,7 @@ writeDirectoriesSafe opts dirs = fmap or $ for dirs $ \dir -> do

go dir exists

message opts T.Log $ show action ++ " directory ./" ++ dir ++ "..."
message opts T.Info $ show action ++ " directory ./" ++ dir ++ "..."
return $ action == Existing
where
doOverwrite = _optOverwrite opts
Expand All @@ -312,7 +312,7 @@ writeDirectoriesSafe opts dirs = fmap or $ for dirs $ \dir -> do
createDirectory dir
| exists && doOverwrite = do
newDir <- findNewPath dir
message opts T.Log $
message opts T.Info $
concat
[ dir
, " already exists. Backing up old version in "
Expand Down
12 changes: 9 additions & 3 deletions cabal-install/src/Distribution/Client/Init/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ instance Interactive IO where
hFlush = System.IO.hFlush
message q severity msg
| q == silent = pure ()
| otherwise = putStrLn $ "[" ++ show severity ++ "] " ++ msg
| otherwise = putStrLn $ "[" ++ displaySeverity severity ++ "] " ++ msg
break = return False
throwPrompt = throwM

Expand Down Expand Up @@ -407,7 +407,7 @@ instance Interactive PurePrompt where
Error -> PurePrompt $ \_ ->
Left $
BreakException
(show severity ++ ": " ++ msg)
(displaySeverity severity ++ ": " ++ msg)
_ -> return ()

break = return True
Expand Down Expand Up @@ -455,7 +455,13 @@ newtype BreakException = BreakException String deriving (Eq, Show)
instance Exception BreakException

-- | Used to inform the intent of prompted messages.
data Severity = Log | Info | Warning | Error deriving (Eq, Show)
data Severity = Info | Warning | Error deriving (Eq)

displaySeverity :: Severity -> String
displaySeverity severity = case severity of
Info -> "Info"
Warning -> "Warn"
Error -> "Err"

-- | Convenience alias for the literate haskell flag
type IsLiterate = Bool
Expand Down
2 changes: 1 addition & 1 deletion cabal-install/src/Distribution/Client/Init/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ retrieveDependencies v flags mods' pkgIx = do
modDeps = map (\(mn, ds) -> (mn, ds, M.lookup ds modMap)) mods
-- modDeps = map (id &&& flip M.lookup modMap) mods

message v Log "Guessing dependencies..."
message v Info "Guessing dependencies..."
nub . catMaybes <$> traverse (chooseDep v flags) modDeps

-- Given a module and a list of installed packages providing it,
Expand Down
12 changes: 12 additions & 0 deletions changelog.d/pr-9346
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
synopsis: remove
packages: cabal-install
prs: #9346
issues: #9151
significance: significant

description: {

- Remove "Log" as a log level in favour of "Info".
- Remove "Show" in Severity and replace by "displaySeverity" function

}

0 comments on commit 00bc7de

Please sign in to comment.