mirror of
https://github.com/nmattia/niv.git
synced 2024-10-06 12:27:35 +03:00
Show more info about sources
This commit is contained in:
parent
723d4e1103
commit
02fa67aa34
@ -581,22 +581,26 @@ parseCmdStatus =
|
||||
|
||||
cmdStatus :: NIO ()
|
||||
cmdStatus = do
|
||||
sjs <- sourcesJsonStatus
|
||||
tsay $ "sources.json: " <> sjs
|
||||
sns <- sourcesNixStatus'
|
||||
tsay $ "sources.nix: " <> sns
|
||||
sourcesJsonStatus
|
||||
sourcesNixStatus'
|
||||
where
|
||||
sourcesJsonStatus = do
|
||||
fsj <- getFindSourcesJson
|
||||
liftIO (getSourcesEither fsj) >>= \case
|
||||
Right (fp, _) -> pure (T.pack fp)
|
||||
Left SourcesDoesntExist -> pure "not found"
|
||||
Left SourceIsntJSON -> pure "not json"
|
||||
Left SpecIsntAMap -> pure "bad format, not a map"
|
||||
Right (fp, sources) -> do
|
||||
tsay $ "sources.json: " <> (T.pack fp)
|
||||
tsay $ "sources.json # of packages: " <> tshow (HMS.size (unSources sources))
|
||||
Left SourcesDoesntExist -> tsay "sources.json: not found"
|
||||
Left SourceIsntJSON -> tsay "sources.json: not json"
|
||||
Left SpecIsntAMap -> tsay "sources.json: bad format, not a map"
|
||||
sourcesNixStatus' = liftIO sourcesNixStatus >>= \case
|
||||
SourcesNixNotFound -> pure "not found"
|
||||
SourcesNixCustom -> pure "custom"
|
||||
SourcesNixFound v -> pure (sourcesVersionToText v) -- TODO add path
|
||||
SourcesNixNotFound -> tsay $ "sources.nix: not found"
|
||||
SourcesNixCustom -> do
|
||||
tsay $ "sources.nix: " <> T.pack pathNixSourcesNix
|
||||
tsay $ "sources.nix version: custom"
|
||||
SourcesNixFound v -> do
|
||||
tsay $ "sources.nix: " <> T.pack pathNixSourcesNix
|
||||
tsay $ "sources.nix version: " <> sourcesVersionToText v
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Files and their content
|
||||
|
@ -250,29 +250,29 @@ warnIfOutdated = do
|
||||
twarn $ T.unwords ["Could not read", T.pack pathNixSourcesNix]
|
||||
SourcesNixCustom -> pure ()
|
||||
SourcesNixFound v
|
||||
-- The file is the latest
|
||||
| v == maxBound -> pure ()
|
||||
-- The file is older than than latest
|
||||
| otherwise -> do
|
||||
tsay $
|
||||
T.unlines
|
||||
[ T.unwords
|
||||
[ tbold $ tblue "INFO:",
|
||||
"new sources.nix available:",
|
||||
sourcesVersionToText v,
|
||||
"->",
|
||||
sourcesVersionToText maxBound
|
||||
],
|
||||
" Please run 'niv init' or add the following line in the "
|
||||
<> T.pack pathNixSourcesNix
|
||||
<> " file:",
|
||||
" # niv: no_update"
|
||||
]
|
||||
-- The file is the latest
|
||||
| v == maxBound -> pure ()
|
||||
-- The file is older than than latest
|
||||
| otherwise -> do
|
||||
tsay $
|
||||
T.unlines
|
||||
[ T.unwords
|
||||
[ tbold $ tblue "INFO:",
|
||||
"new sources.nix available:",
|
||||
sourcesVersionToText v,
|
||||
"->",
|
||||
sourcesVersionToText maxBound
|
||||
],
|
||||
" Please run 'niv init' or add the following line in the "
|
||||
<> T.pack pathNixSourcesNix
|
||||
<> " file:",
|
||||
" # niv: no_update"
|
||||
]
|
||||
|
||||
data SourcesNixStatus =
|
||||
SourcesNixNotFound |
|
||||
SourcesNixCustom |
|
||||
SourcesNixFound SourcesNixVersion
|
||||
data SourcesNixStatus
|
||||
= SourcesNixNotFound
|
||||
| SourcesNixCustom
|
||||
| SourcesNixFound SourcesNixVersion
|
||||
|
||||
-- | Get the status of the sources.nix
|
||||
sourcesNixStatus :: IO SourcesNixStatus
|
||||
|
Loading…
Reference in New Issue
Block a user