diff --git a/src/Main.hs b/src/Main.hs index 3ac5745..aa89fb4 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -35,7 +35,8 @@ import Data.Maybe (mapMaybe) import qualified Text.URI as URI import System.Directory (listDirectory) import qualified Data.HashMap.Strict as HashMap -import SlackBuilder.Info (readInfoFile) +import SlackBuilder.Info (PackageInfo(..), readInfoFile) +import Control.Monad (unless) autoUpdatable :: [PackageSettings] -> [PackageDescription] autoUpdatable = mapMaybe go @@ -108,9 +109,10 @@ installed = do <$> liftIO (listDirectory "/var/lib/pkgtools/packages") traverse_ findInfo $ HashMap.intersectionWith (,) database listing where - findInfo (installed'@Package.DataBaseEntry{ name }, fromRepository) = do - _ <- readInfoFile fromRepository name - liftIO $ print installed' + 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 diff --git a/src/SlackBuilder/CommandLine.hs b/src/SlackBuilder/CommandLine.hs index 3163fb9..ee81289 100644 --- a/src/SlackBuilder/CommandLine.hs +++ b/src/SlackBuilder/CommandLine.hs @@ -14,12 +14,13 @@ import Options.Applicative , ParserInfo(..) , metavar , argument + , helper , str , info , fullDesc , subparser , command - , optional + , optional, progDesc ) data SlackBuilderCommand @@ -28,15 +29,20 @@ data SlackBuilderCommand | InstalledCommand slackBuilderParser :: ParserInfo SlackBuilderCommand -slackBuilderParser = info slackBuilderCommand fullDesc +slackBuilderParser = info (helper <*> slackBuilderCommand) fullDesc slackBuilderCommand :: Parser SlackBuilderCommand slackBuilderCommand = subparser - $ command "check" (info checkCommand mempty) - <> command "up2date" (info up2DateCommand mempty) - <> command "installed" (info installedCommand mempty) + $ command "check" checkCommand + <> command "up2date" up2DateCommand + <> command "installed" installedCommand where - checkCommand = pure CheckCommand - up2DateCommand = Up2DateCommand + checkCommand = info checkP $ progDesc "Check all configured slackbuilds for updates" + checkP = pure CheckCommand + up2DateP = Up2DateCommand <$> optional (argument str (metavar "PKGNAM")) - installedCommand = pure InstalledCommand + up2DateCommand = info up2DateP + $ 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