Skip to content

Commit df2f667

Browse files
committed
pretty up some s/S/Package functions
1 parent d527173 commit df2f667

1 file changed

Lines changed: 32 additions & 19 deletions

File tree

src/Stack/Package.hs

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -644,9 +644,12 @@ resolveGlobFiles =
644644
(\(e :: IOException) ->
645645
if isUserError e
646646
then do
647-
logWarn
648-
("Wildcard does not match any files: " <> T.pack glob <> "\n" <>
649-
"in directory: " <> T.pack dir)
647+
prettyWarnL
648+
[ flow "Wildcard does not match any files:"
649+
, styleFile $ fromString glob
650+
, line <> flow "in directory:"
651+
, styleDir $ fromString dir
652+
]
650653
return []
651654
else throwIO e)
652655

@@ -665,7 +668,7 @@ resolveGlobFiles =
665668
-- ["test/package-dump/ghc-7.8.txt","test/package-dump/ghc-7.10.txt"]
666669
-- @
667670
--
668-
matchDirFileGlob_ :: (MonadLogger m, MonadIO m) => String -> String -> m [String]
671+
matchDirFileGlob_ :: (MonadLogger m, MonadIO m, HasRunner env, MonadReader env m) => String -> String -> m [String]
669672
matchDirFileGlob_ dir filepath = case parseFileGlob filepath of
670673
Nothing -> liftIO $ throwString $
671674
"invalid file glob '" ++ filepath
@@ -685,7 +688,11 @@ matchDirFileGlob_ dir filepath = case parseFileGlob filepath of
685688
, not (null name) && isSuffixOf ext ext'
686689
]
687690
when (null matches) $
688-
logWarn $ "WARNING: filepath wildcard '" <> T.pack filepath <> "' does not match any files."
691+
prettyWarnL
692+
[ flow "filepath wildcard"
693+
, "'" <> styleFile (fromString filepath) <> "'"
694+
, flow "does not match any files."
695+
]
689696
return matches
690697

691698
-- | Get all files referenced by the benchmark.
@@ -1053,8 +1060,12 @@ parseDumpHI dumpHIPath = do
10531060
thDepsResolved <- liftM catMaybes $ forM thDeps $ \x -> do
10541061
mresolved <- liftIO (forgivingAbsence (resolveFile dir x)) >>= rejectMissingFile
10551062
when (isNothing mresolved) $
1056-
logWarn $ "Warning: addDependentFile path (Template Haskell) listed in " <> T.pack dumpHIPath <>
1057-
" does not exist: " <> T.pack x
1063+
prettyWarnL
1064+
[ flow "addDependentFile path (Template Haskell) listed in"
1065+
, styleFile $ fromString dumpHIPath
1066+
, flow "does not exist:"
1067+
, styleFile $ fromString x
1068+
]
10581069
return mresolved
10591070
return (moduleDeps, thDepsResolved)
10601071

@@ -1128,20 +1139,22 @@ findCandidate dirs exts name = do
11281139
-- | Warn the user that multiple candidates are available for an
11291140
-- entry, but that we picked one anyway and continued.
11301141
warnMultiple
1131-
:: MonadLogger m
1142+
:: (MonadLogger m, HasRunner env, MonadReader env m)
11321143
=> DotCabalDescriptor -> Path b t -> [Path b t] -> m ()
11331144
warnMultiple name candidate rest =
1134-
logWarn
1135-
("There were multiple candidates for the Cabal entry \"" <>
1136-
showName name <>
1137-
"\" (" <>
1138-
T.intercalate "," (map (T.pack . toFilePath) rest) <>
1139-
"), picking " <>
1140-
T.pack (toFilePath candidate))
1141-
where showName (DotCabalModule name') = T.pack (D.display name')
1142-
showName (DotCabalMain fp) = T.pack fp
1143-
showName (DotCabalFile fp) = T.pack fp
1144-
showName (DotCabalCFile fp) = T.pack fp
1145+
-- TODO: figure out how to style 'name' and the dispOne stuff
1146+
prettyWarnL
1147+
[ flow "There were multiple candidates for the Cabal entry \""
1148+
, fromString . showName $ name
1149+
, line <> bulletedList (map dispOne rest)
1150+
, line <> flow "picking:"
1151+
, dispOne candidate
1152+
]
1153+
where showName (DotCabalModule name') = D.display name'
1154+
showName (DotCabalMain fp) = fp
1155+
showName (DotCabalFile fp) = fp
1156+
showName (DotCabalCFile fp) = fp
1157+
dispOne = fromString . toFilePath
11451158

11461159
-- | Log that we couldn't find a candidate, but there are
11471160
-- possibilities for custom preprocessor extensions.

0 commit comments

Comments
 (0)