[package-plan] 01/01: lts-diff.hs: Added command line switches to switch off some reports.

Sven Bartscher svenb-guest at moszumanska.debian.org
Tue Mar 15 18:24:31 UTC 2016


This is an automated email from the git hooks/post-receive script.

svenb-guest pushed a commit to branch master
in repository package-plan.

commit d85c551887d400d37abc08a3a56d0e7b66e755b8
Author: Sven Bartscher <sven.bartscher at weltraumschlangen.de>
Date:   Tue Mar 15 19:24:01 2016 +0100

    lts-diff.hs: Added command line switches to switch off some reports.
---
 lts-diff.hs | 32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/lts-diff.hs b/lts-diff.hs
index dea8085..8edfbd9 100644
--- a/lts-diff.hs
+++ b/lts-diff.hs
@@ -1,12 +1,15 @@
 import Control.Applicative ((<$>))
-import Control.Monad (void)
+import Control.Monad (void, unless)
 import Data.Maybe (mapMaybe)
 import Data.List (intercalate)
 import Data.List.Split (splitOn)
 import Data.Char (isAlpha)
 import qualified Data.Foldable as F
+import qualified Data.Traversable as T
 import qualified Data.Set as S
 import qualified Data.Map as M
+import System.Environment (getArgs)
+import System.Exit (exitFailure)
 import Distribution.Package ( PackageId
                             , PackageName(PackageName)
                             , PackageIdentifier(PackageIdentifier)
@@ -21,12 +24,33 @@ import Safe (readMay)
 
 main :: IO ()
 main = do
+  (pmiss, pdiff, pmore) <- parseArgs
   debian <- getDebianPackages
   lts <- getLtsPackages
   let (missing, different, more) = packageDiff debian lts
-  printMissings missing
-  printDifferences different
-  printMore more
+  unless pmiss $ printMissings missing
+  unless pdiff $ printDifferences different
+  unless pmore $ printMore more
+
+parseArgs :: IO (Bool, Bool, Bool)
+parseArgs = do
+  r <- T.sequence <$> map isValid <$> getArgs
+  case r of
+    Left arg -> do
+              putStrLn $ "Invalid command line argument " ++ arg
+              exitFailure
+    Right args -> let pmiss = "--no-missing-packages" `elem` args
+                      pdiff = "--no-differing-packages" `elem` args
+                      pmore = "--no-more-packages" `elem` args
+                  in return (pmiss, pdiff, pmore)
+
+isValid :: String -> Either String String
+isValid arg = if arg `elem` [ "--no-missing-packages"
+                           , "--no-differing-packages"
+                           , "--no-more-packages"
+                           ]
+              then Right arg
+              else Left arg
 
 getDebianPackages :: IO (S.Set PackageId)
 getDebianPackages = S.fromList . mapMaybe parseDebianPackage

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-haskell/package-plan.git



More information about the Pkg-haskell-commits mailing list