Permalink
Browse files

Merge pull request #7 from reinerp/master

Add Config.Dyre.Options.removeDyreOptions
  • Loading branch information...
2 parents 6ee75c7 + 287813d commit 54d331883a1ced45946a9e5f22dfb3b40d4a5f92 @willdonnelly committed Jul 26, 2012
Showing with 8 additions and 4 deletions.
  1. +8 −4 Config/Dyre/Options.hs
View
@@ -17,7 +17,8 @@ control over to a new binary, it gets an argument list which
preserves the important flags with a call to 'customOptions'.
-}
module Config.Dyre.Options
- ( withDyreOptions
+ ( removeDyreOptions
+ , withDyreOptions
, customOptions
, getDenyReconf
, getForceReconf
@@ -34,6 +35,11 @@ import System.Environment.Executable
import Config.Dyre.Params
+-- | Remove all Dyre's options from the given commandline arguments.
+removeDyreOptions :: [String] -> [String]
+removeDyreOptions = filter $ not . prefixElem dyreArgs
+ where prefixElem xs = or . zipWith ($) (map isPrefixOf xs) . repeat
+
-- | Store Dyre's command-line options to the IO-Store "dyre",
-- and then execute the provided IO action with all Dyre's
-- options removed from the command-line arguments.
@@ -57,9 +63,7 @@ withDyreOptions Params{configCheck = check} action = withStore "dyre" $ do
putValue "dyre" "debugMode" $ "--dyre-debug" `elem` args
-- We filter the arguments, so now Dyre's arguments 'vanish'
- withArgs (filterArgs args) action
- where filterArgs = filter $ not . prefixElem dyreArgs
- prefixElem xs = or . zipWith ($) (map isPrefixOf xs) . repeat
+ withArgs (removeDyreOptions args) action
-- | Get the value of the '--force-reconf' flag, which is used
-- to force a recompile of the custom configuration.

0 comments on commit 54d3318

Please sign in to comment.