Skip to content

Commit

Permalink
Support full 'allow-newer' syntax in the config file.
Browse files Browse the repository at this point in the history
  • Loading branch information
23Skidoo committed Feb 20, 2016
1 parent b428a2e commit b402dc8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
14 changes: 6 additions & 8 deletions Cabal/Distribution/Simple/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,9 @@ isAllowNewer AllowNewerNone = False
isAllowNewer (AllowNewerSome _) = True
isAllowNewer AllowNewerAll = True

allowNewerParser :: ReadE (Maybe AllowNewer)
allowNewerParser = ReadE $ \s ->
case readPToMaybe pkgsParser s of
Just pkgs -> Right . Just . AllowNewerSome $ pkgs
Nothing -> Left ("Cannot parse the list of packages: " ++ s)
where
pkgsParser = Parse.sepBy1 parse (Parse.char ',')
allowNewerParser :: Parse.ReadP r (Maybe AllowNewer)
allowNewerParser =
(Just . AllowNewerSome) `fmap` Parse.sepBy1 parse (Parse.char ',')

allowNewerPrinter :: (Maybe AllowNewer) -> [Maybe String]
allowNewerPrinter Nothing = []
Expand Down Expand Up @@ -687,7 +683,9 @@ configureOptions showOrParseArgs =
,option [] ["allow-newer"]
("Ignore upper bounds in all dependencies or DEPS")
configAllowNewer (\v flags -> flags { configAllowNewer = v})
(optArg "DEPS" allowNewerParser (Just AllowNewerAll) allowNewerPrinter)
(optArg "DEPS"
(readP_to_E ("Cannot parse the list of packages: " ++) allowNewerParser)
(Just AllowNewerAll) allowNewerPrinter)

,option "" ["exact-configuration"]
"All direct dependencies and flags are provided on the command line."
Expand Down
3 changes: 2 additions & 1 deletion Cabal/doc/installing-packages.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,8 @@ be controlled with the following command line options.
~~~~~~~~~~~~~~~~

Finally, one can enable `--allow-newer` permanently by setting `allow-newer:
True` in the `~/.cabal/config` file.
True` in the `~/.cabal/config` file. Enabling 'allow-newer' selectively is
also supported in the config file (`allow-newer: foo, bar, baz:base`).

`--constraint=`_constraint_
: Restrict solutions involving a package to a given version range.
Expand Down
7 changes: 4 additions & 3 deletions cabal-install/Distribution/Client/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ import Distribution.ParseUtils
, locatedErrorMsg, showPWarning
, readFields, warning, lineNo
, simpleField, listField, spaceListField
, parseFilePathQ, parseTokenQ )
, parseFilePathQ, parseOptCommaList, parseTokenQ )
import Distribution.Client.ParseUtils
( parseFields, ppFields, ppSection )
import Distribution.Client.HttpUtils
Expand Down Expand Up @@ -108,7 +108,7 @@ import Data.Monoid
import Control.Monad
( when, unless, foldM, liftM, liftM2 )
import qualified Distribution.Compat.ReadP as Parse
( option )
( (<++), option )
import Distribution.Compat.Semigroup
( Semigroup((<>)) )
import qualified Text.PrettyPrint as Disp
Expand Down Expand Up @@ -677,7 +677,8 @@ configFieldDescriptions src =
toAllowNewer True = Just AllowNewerAll
toAllowNewer False = Just AllowNewerNone

parseAllowNewer = toAllowNewer `fmap` Text.parse in
pkgs = (Just . AllowNewerSome) `fmap` parseOptCommaList Text.parse
parseAllowNewer = (toAllowNewer `fmap` Text.parse) Parse.<++ pkgs in
simpleField "allow-newer"
showAllowNewer parseAllowNewer
configAllowNewer (\v flags -> flags { configAllowNewer = v })
Expand Down

0 comments on commit b402dc8

Please sign in to comment.