Skip to content
This repository was archived by the owner on Dec 7, 2023. It is now read-only.

Commit df070ff

Browse files
authored
Update yasi (#16)
1 parent 9441c5d commit df070ff

File tree

18 files changed

+128
-119
lines changed

18 files changed

+128
-119
lines changed

flake.lock

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hellsmack.cabal

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ library
2929

3030
build-depends:
3131
relude >= 1.0
32+
, text >= 1.2
3233
, split >= 0.2
3334
, these >= 1.1
3435
, semialign >= 1.2
@@ -45,7 +46,8 @@ library
4546
, deriving-aeson >= 0.2.7
4647
, lens-aeson >= 1.1
4748
, time >= 1.9
48-
, yasi >= 0.1.1
49+
, yasi >= 0.2
50+
, text-display >= 0.0
4951
, binary >= 0.8
5052
, exceptions >= 0.10
5153
, unliftio >= 0.2
@@ -92,7 +94,7 @@ library
9294
HellSmack.Util.Meta
9395
HellSmack.Util.Minecraft
9496
HellSmack.Util.Murmur
95-
HellSmack.Util.Newtypes
97+
HellSmack.Util.Orphans
9698
HellSmack.Util.Path
9799
HellSmack.Util.Terminal
98100
HellSmack.Http

src/HellSmack/Curse.hs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,18 @@ downloadFullModpack ModpackInstallOptions {..} = do
106106
es <- mkEntrySelector "manifest.json"
107107
getEntry es >>= decodeJSON . toLazy
108108
let modpackVersion = C.formatWith [C.bold] $ manifest ^. #version
109-
mcVersion :: Text = C.formatWith [C.bold] $ show $ manifest ^. #minecraft . #version
109+
mcVersion = C.formatWith [C.bold] $ display $ manifest ^. #minecraft . #version
110110
logInfo [i|modpack version: $modpackVersion, MC version: $mcVersion|]
111111
forOf_
112112
do #minecraft . #modLoaders . each . filtered (^. #primary)
113113
manifest
114-
\ModLoaderInfo {id} -> logInfo $ [i|mod loader: ${}|] $ C.formatWith [C.bold] id
114+
\ModLoaderInfo {id} -> logInfo [i|mod loader: ${C.formatWith [C.bold] id}|]
115115

116116
let (optionalFileIds, requiredFileIds) =
117117
manifest ^. #files & partitionWith \f ->
118118
(chosen %~ (^. #fileID)) . bool Left Right (f ^. #required) $ f
119119

120-
logInfo $ [i|fetching metadata of $show mods|] $ length requiredFileIds
120+
logInfo [i|fetching metadata of ${length requiredFileIds} mods|]
121121
files <- getAddonFilesByFileIds requiredFileIds <&> (^.. each . folded)
122122

123123
let modDir = outDir </> [reldir|mods|]
@@ -128,24 +128,24 @@ downloadFullModpack ModpackInstallOptions {..} = do
128128
(unzip -> (_, knownOldMods), trulyNewMods, sameMods) =
129129
partitionThese . M.elems $ M.fromList oldModsByFP `align` M.fromList newModsByFP
130130
deletableOldFiles = unknownMods <> knownOldMods
131-
for_ sameMods \((oldFile, toFilePath -> p), newFile) ->
131+
for_ sameMods \((oldFile, p), newFile) ->
132132
when (oldFile ^. #id /= newFile ^. #id) $ throwString [i|internal ID conflict for mod $p|]
133133

134-
whenNotNull sameMods $ logInfo . [i|$show mods already present|] . length
134+
whenNotNull sameMods $ logInfo . [i|${} mods already present|] . length
135135

136136
case trulyNewMods of
137137
[] -> logInfo "no new mods need to be downloaded"
138138
_ -> do
139139
let modSize = showBytes' $ sumOf (each . #fileLength) trulyNewMods
140140
modCount = length trulyNewMods
141-
logInfo [i|downloading ${show modCount} mods ($modSize)|]
141+
logInfo [i|downloading $modCount mods ($modSize)|]
142142
stepWise (withGenericProgress modCount) \step ->
143143
forConcurrentlyNetwork_ trulyNewMods \a -> step $ downloadAddonFile a modDir HideProgress
144144

145145
whenNotNull deletableOldFiles \_ -> do
146-
logInfo $ [i|deleting $show stale mod files|] (length deletableOldFiles)
146+
logInfo [i|deleting ${length deletableOldFiles} stale mod files|]
147147
for_ deletableOldFiles \p -> do
148-
logTrace $ [i| - ${}|] $ toFilePath p
148+
logTrace [i| - $p|]
149149
removeFile p
150150

151151
whenNotNull optionalFileIds \_ -> do
@@ -238,7 +238,7 @@ searchInstallModpack ModpackSearchInstallOptions {..} = do
238238
Just <$> selectViaTable addons ["name", "authors", "download count"] \a ->
239239
[ formattedVia C.green . toString $ a ^. #name,
240240
TL.plain . intercalate ", " $ a ^.. #authors . each . #name . unpacked,
241-
TL.plain . show @_ @Int . round $ a ^. #downloadCount
241+
TL.plain . toString . display @Int . round $ a ^. #downloadCount
242242
]
243243
whenJust addon \addon -> do
244244
files <-
@@ -310,8 +310,8 @@ findInCurseDB inputs = do
310310
Just FingerprintMatch {..} -> Right (id, file, path)
311311
Nothing -> Left path
312312
unless (null unknown) do
313-
logWarn $ [i|these ${show} files are not present in the CurseForge mod database:|] $ length unknown
314-
for_ unknown $ logWarn . [i| - ${}|] . toFilePath
313+
logWarn [i|these ${length unknown} files are not present in the CurseForge mod database:|]
314+
for_ unknown $ logWarn . [i| - ${}|]
315315
pure result
316316

317317
data ModLoader = ForgeModLoader | FabricModLoader
@@ -336,7 +336,7 @@ updateMods ModUpdateOptions {..} = do
336336
outDir <- outDir & _Just %%~ makeSomeAbsolute
337337
(_, updatable) <- findInCurseDB inputs
338338
unless (null updatable) do
339-
logInfo $ [i|fetching update info for $show mods|] $ length updatable
339+
logInfo [i|fetching update info for ${length updatable} mods|]
340340
let isNewerFile file f =
341341
f ^. #fileDate > file ^. #fileDate
342342
&& case mcVersion of
@@ -361,7 +361,7 @@ updateMods ModUpdateOptions {..} = do
361361
let addonName c a = C.formatWith c $ a ^. #name
362362
fileName c f = C.formatWith c $ f ^. #displayName
363363
case newerFiles of
364-
Nothing -> logInfo $ [i|no updates for ${}|] $ addonName [C.bold] addon
364+
Nothing -> logInfo [i|no updates for ${addonName [C.bold] addon}|]
365365
Just newerFiles -> do
366366
let an = addonName [C.bold, C.green] addon
367367
fn = fileName [C.bold] file
@@ -379,7 +379,7 @@ updateMods ModUpdateOptions {..} = do
379379
if newFile ^. #id == file ^. #id
380380
then logInfo "staying on current version"
381381
else do
382-
logInfo $ [i|updating to ${}|] $ fileName [C.green, C.bold] newFile
382+
logInfo [i|updating to ${fileName [C.green, C.bold] newFile}|]
383383
downloadAddonFile newFile (outDir ?: parent path) ShowProgress
384384
unless keepOld $ removeFile path
385385
where
@@ -406,7 +406,7 @@ installMods ModsInstallOptions {..} = do
406406
whenNotNull
407407
do toList $ S.fromList fileIds S.\\ S.fromList (addonFiles ^.. each . to head . #id)
408408
\(coerce @_ @[Int] . toList -> unknownFileIds) ->
409-
throwString $ [i|unknown file IDs: ${}|] $ T.intercalate ", " $ show <$> unknownFileIds
409+
throwString $ [i|unknown file IDs: ${}|] $ T.intercalate ", " $ display <$> unknownFileIds
410410
addons <- getAddons (addonFiles ^.. ifolded . asIndex) <&> M.fromList . fmapToFst (^. #id)
411411
ensureDir outDir
412412
addonFiles <- forM (itoList addonFiles) \(aid, file :| _) -> do
@@ -422,7 +422,7 @@ installMods ModsInstallOptions {..} = do
422422
[ formattedVia (C.bold <> C.green) . toString $ addon ^. #name,
423423
formattedVia C.bold . toString $ file ^. #displayName
424424
]
425-
logInfo $ [i|downloading $show mods|] $ length addonFiles
425+
logInfo [i|downloading ${length addonFiles} mods|]
426426
forConcurrentlyNetwork_ (addonFiles `zip` tableLines) \((_, file), line) -> do
427427
logInfo $ toText line
428428
downloadAddonFile file outDir HideProgress
@@ -469,10 +469,10 @@ searchInstallMod ModSearchInstallOptions {..} = do
469469
Just <$> selectViaTable addons ["name", "authors", "download count"] \a ->
470470
[ formattedVia C.green . toString $ a ^. #name,
471471
TL.plain . intercalate ", " $ a ^.. #authors . each . #name . unpacked,
472-
TL.plain . show @_ @Int . round $ a ^. #downloadCount
472+
TL.plain . toString . display @Int . round $ a ^. #downloadCount
473473
]
474474
whenJust addon \a@Addon {name = addonName} -> do
475-
logInfo $ [i|selected ${}|] $ C.formatWith [C.green, C.bold] addonName
475+
logInfo [i|selected ${C.formatWith [C.green, C.bold] addonName}|]
476476
whenJustM (selectAddonFile a) \file -> do
477477
ensureDir outDir
478478
downloadAddonFile file outDir ShowProgress
@@ -481,7 +481,7 @@ searchInstallMod ModSearchInstallOptions {..} = do
481481
logInfo [i|fetching dependency metadata|]
482482
deps <- findDeps requiredDependencyType file
483483
whenNotNull deps \deps -> do
484-
logInfo $ [i|downloading ${} dependencies|] $ C.formatWith [C.green, C.bold] addonName
484+
logInfo [i|downloading ${C.formatWith [C.green, C.bold] addonName} dependencies|]
485485
stepWise (withGenericProgress (length deps)) \step ->
486486
forConcurrentlyNetwork_ deps \file ->
487487
step $ downloadAddonFile file outDir HideProgress
@@ -503,7 +503,7 @@ searchInstallMod ModSearchInstallOptions {..} = do
503503
TL.plain . toString . showBytes' $ f ^. #fileLength
504504
]
505505
whenJust file \AddonFile {displayName = modFileName} ->
506-
logInfo $ [i|selected ${}|] $ C.formatWith [C.green, C.bold] modFileName
506+
logInfo [i|selected ${C.formatWith [C.green, C.bold] modFileName}|]
507507
pure file
508508

509509
findDeps dt =
@@ -545,8 +545,8 @@ deduplicateMods ModDeduplicateOptions {..} = do
545545
& \case
546546
[] -> logInfo [i|no duplicated mods found|]
547547
toBeRemoved -> do
548-
logInfo $ [i|removing $show old mods:|] $ length toBeRemoved
549-
for_ toBeRemoved $ logInfo . [i| - ${}|] . toFilePath
548+
logInfo [i|removing ${length toBeRemoved} old mods:|]
549+
for_ toBeRemoved $ logInfo . [i| - ${}|]
550550
promptBool "remove" >>= \case
551551
True -> logInfo "removing old mods" *> for_ toBeRemoved removeFile
552552
False -> logInfo "keeping old mods"

0 commit comments

Comments
 (0)