Skip to content

Commit

Permalink
Merge pull request #7 from reinerp/master
Browse files Browse the repository at this point in the history
Add Config.Dyre.Options.removeDyreOptions
  • Loading branch information
willdonnelly committed Jul 26, 2012
2 parents 6ee75c7 + 287813d commit 54d3318
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Config/Dyre/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit 54d3318

Please sign in to comment.