[commit: Cabal] master: Parse command line arguments as either Dependency or PackageIDentifier, to allow e.g. 'cabal install binary-0.3'. (7216fb7)
Ian Lynagh
igloo at earth.li
Fri Jun 24 01:48:04 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/Cabal
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/7216fb76586a9d3e8c4cd57dde64b12d39200500
>---------------------------------------------------------------
commit 7216fb76586a9d3e8c4cd57dde64b12d39200500
Author: bjorn <bjorn at bringert.net>
Date: Wed Oct 17 21:11:26 2007 +0000
Parse command line arguments as either Dependency or PackageIDentifier, to allow e.g. 'cabal install binary-0.3'.
>---------------------------------------------------------------
cabal-install/Hackage/Setup.hs | 5 ++---
cabal-install/Hackage/Utils.hs | 9 +++++++--
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/cabal-install/Hackage/Setup.hs b/cabal-install/Hackage/Setup.hs
index 6962a10..133850c 100644
--- a/cabal-install/Hackage/Setup.hs
+++ b/cabal-install/Hackage/Setup.hs
@@ -17,7 +17,6 @@ module Hackage.Setup
) where
import Control.Monad (when)
-import Distribution.ParseUtils (parseDependency)
import Distribution.Compiler (CompilerFlavor(..))
import Distribution.Simple.InstallDirs (InstallDirTemplates(..), toPathTemplate)
import Distribution.Verbosity
@@ -28,7 +27,7 @@ import System.Environment (getProgName)
import Hackage.Types (Action (..), Option(..), ConfigFlags(..)
, UnresolvedDependency (..))
-import Hackage.Utils (readPToMaybe)
+import Hackage.Utils (readPToMaybe, parseDependencyOrPackageId)
globalOptions :: [OptDescr Option]
@@ -192,7 +191,7 @@ parsePackageArgs _ args
= return (globalArgs,parsePkgArgs pkgs)
where (globalArgs,pkgs) = break (not.(==)'-'.head) args
parseDep dep
- = case readPToMaybe parseDependency dep of
+ = case readPToMaybe parseDependencyOrPackageId dep of
Nothing -> error ("Failed to parse package dependency: " ++ show dep)
Just x -> x
parsePkgArgs [] = []
diff --git a/cabal-install/Hackage/Utils.hs b/cabal-install/Hackage/Utils.hs
index 5a0ee42..dc02760 100644
--- a/cabal-install/Hackage/Utils.hs
+++ b/cabal-install/Hackage/Utils.hs
@@ -1,11 +1,12 @@
module Hackage.Utils where
-import Distribution.Compat.ReadP (ReadP, readP_to_S, pfail, get, look, choice)
+import Distribution.Compat.ReadP (ReadP, readP_to_S, pfail, get, look, choice, (+++))
+import Distribution.Package (PackageIdentifier(..), parsePackageId)
import Distribution.ParseUtils
import Distribution.Version
import Control.Exception
-import Control.Monad (foldM, guard)
+import Control.Monad (foldM, liftM, guard)
import Data.Char (isSpace, toLower)
import Data.List (intersperse)
import Data.Maybe (listToMaybe)
@@ -85,3 +86,7 @@ stringNoCase this = look >>= scan this
showDependencies :: [Dependency] -> String
showDependencies = concat . intersperse ", " . map (show . showDependency)
+
+parseDependencyOrPackageId :: ReadP r Dependency
+parseDependencyOrPackageId = parseDependency +++ liftM pkgToDep parsePackageId
+ where pkgToDep p = Dependency (pkgName p) (ThisVersion (pkgVersion p))
\ No newline at end of file
More information about the Cvs-libraries
mailing list