Remove the installed command
Since it is out of scope for this project.
This commit is contained in:
parent
8908b8ae93
commit
731a36d700
32
src/Main.hs
32
src/Main.hs
@ -17,7 +17,6 @@ import SlackBuilder.LatestVersionCheck
|
|||||||
import SlackBuilder.Update
|
import SlackBuilder.Update
|
||||||
import qualified Toml
|
import qualified Toml
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
import qualified Data.Text as Text
|
|
||||||
import qualified Data.Text.IO as Text
|
import qualified Data.Text.IO as Text
|
||||||
import Control.Monad.Trans.Reader (ReaderT(..), asks)
|
import Control.Monad.Trans.Reader (ReaderT(..), asks)
|
||||||
import SlackBuilder.Package (PackageDescription(..), renderTextWithVersion)
|
import SlackBuilder.Package (PackageDescription(..), renderTextWithVersion)
|
||||||
@ -33,10 +32,6 @@ import System.Console.ANSI
|
|||||||
)
|
)
|
||||||
import Data.Maybe (mapMaybe)
|
import Data.Maybe (mapMaybe)
|
||||||
import qualified Text.URI as URI
|
import qualified Text.URI as URI
|
||||||
import System.Directory (listDirectory)
|
|
||||||
import qualified Data.HashMap.Strict as HashMap
|
|
||||||
import SlackBuilder.Info (PackageInfo(..), readInfoFile)
|
|
||||||
import Control.Monad (unless)
|
|
||||||
|
|
||||||
autoUpdatable :: [PackageSettings] -> [PackageDescription]
|
autoUpdatable :: [PackageSettings] -> [PackageDescription]
|
||||||
autoUpdatable = mapMaybe go
|
autoUpdatable = mapMaybe go
|
||||||
@ -102,32 +97,6 @@ check = SlackBuilderT (asks (getField @"packages"))
|
|||||||
>>= mapM_ checkUpdateAvailability
|
>>= mapM_ checkUpdateAvailability
|
||||||
>> liftIO (putStrLn "")
|
>> liftIO (putStrLn "")
|
||||||
|
|
||||||
installed :: SlackBuilderT ()
|
|
||||||
installed = do
|
|
||||||
listing <- listRepository
|
|
||||||
database <- foldr createDataBase HashMap.empty . mapMaybe createEntry
|
|
||||||
<$> liftIO (listDirectory "/var/lib/pkgtools/packages")
|
|
||||||
traverse_ findInfo $ HashMap.intersectionWith (,) database listing
|
|
||||||
where
|
|
||||||
findInfo (installed'@Package.DataBaseEntry{ name, version }, fromRepository) = do
|
|
||||||
packageInfo <- readInfoFile fromRepository name
|
|
||||||
unless (version == getField @"version" packageInfo) $ liftIO $ putStrLn $
|
|
||||||
show installed' <> " (available: " <> Text.unpack (getField @"version" packageInfo) <> ")"
|
|
||||||
createDataBase entry@Package.DataBaseEntry{ name } =
|
|
||||||
HashMap.insert name entry
|
|
||||||
createEntry filename = createEntryFromChunks
|
|
||||||
$ Text.split (== '-')
|
|
||||||
$ Text.reverse
|
|
||||||
$ Text.pack filename
|
|
||||||
createEntryFromChunks (build : arch : version : name) = Just
|
|
||||||
Package.DataBaseEntry
|
|
||||||
{ arch = Text.reverse arch
|
|
||||||
, build = Text.reverse build
|
|
||||||
, version = Text.reverse version
|
|
||||||
, name = Text.reverse (Text.intercalate "-" name)
|
|
||||||
}
|
|
||||||
createEntryFromChunks _ = Nothing
|
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = execParser slackBuilderParser
|
main = execParser slackBuilderParser
|
||||||
>>= handleExceptions . withCommandLine
|
>>= handleExceptions . withCommandLine
|
||||||
@ -147,4 +116,3 @@ main = execParser slackBuilderParser
|
|||||||
executeCommand = \case
|
executeCommand = \case
|
||||||
CheckCommand -> check
|
CheckCommand -> check
|
||||||
Up2DateCommand packageName -> up2Date packageName
|
Up2DateCommand packageName -> up2Date packageName
|
||||||
InstalledCommand -> installed
|
|
||||||
|
@ -26,7 +26,6 @@ import Options.Applicative
|
|||||||
data SlackBuilderCommand
|
data SlackBuilderCommand
|
||||||
= CheckCommand
|
= CheckCommand
|
||||||
| Up2DateCommand (Maybe Text)
|
| Up2DateCommand (Maybe Text)
|
||||||
| InstalledCommand
|
|
||||||
|
|
||||||
slackBuilderParser :: ParserInfo SlackBuilderCommand
|
slackBuilderParser :: ParserInfo SlackBuilderCommand
|
||||||
slackBuilderParser = info (helper <*> slackBuilderCommand) fullDesc
|
slackBuilderParser = info (helper <*> slackBuilderCommand) fullDesc
|
||||||
@ -35,7 +34,6 @@ slackBuilderCommand :: Parser SlackBuilderCommand
|
|||||||
slackBuilderCommand = subparser
|
slackBuilderCommand = subparser
|
||||||
$ command "check" checkCommand
|
$ command "check" checkCommand
|
||||||
<> command "up2date" up2DateCommand
|
<> command "up2date" up2DateCommand
|
||||||
<> command "installed" installedCommand
|
|
||||||
where
|
where
|
||||||
checkCommand = info checkP $ progDesc "Check all configured slackbuilds for updates"
|
checkCommand = info checkP $ progDesc "Check all configured slackbuilds for updates"
|
||||||
checkP = pure CheckCommand
|
checkP = pure CheckCommand
|
||||||
@ -43,6 +41,3 @@ slackBuilderCommand = subparser
|
|||||||
<$> optional (argument str (metavar "PKGNAM"))
|
<$> optional (argument str (metavar "PKGNAM"))
|
||||||
up2DateCommand = info up2DateP
|
up2DateCommand = info up2DateP
|
||||||
$ progDesc "Update a single or multiple slackbuild in the configured repository"
|
$ progDesc "Update a single or multiple slackbuild in the configured repository"
|
||||||
installedCommand = info installedP
|
|
||||||
$ progDesc "Find local packages that can be updated using the configured repository"
|
|
||||||
installedP = pure InstalledCommand
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user