Commit bd4d114c authored by Michael Hanus 's avatar Michael Hanus

info command complete

parent fb73eb48
......@@ -30,7 +30,7 @@ cpmBanner :: String
cpmBanner = unlines [bannerLine,bannerText,bannerLine]
where
bannerText =
"Curry Package Manager <curry-language.org/tools/cpm> (version of 03/02/2017)"
"Curry Package Manager <curry-language.org/tools/cpm> (version of 05/02/2017)"
bannerLine = take (length bannerText) (repeat '-')
--- Data type containing the main configuration of CPM.
......
......@@ -28,6 +28,7 @@ module CPM.Package
, PackageSource (..)
, GitRevision (..)
, showDependency
, showCompilerDependency
, loadPackageSpec
, writePackageSpec
, Conjunction
......@@ -70,7 +71,8 @@ data Dependency = Dependency String Disjunction
--- @cons VLt - version must be strictly smaller than specified version
--- @cons VGte - version must be larger or equal to specified version
--- @cons VLte - version must be smaller or equal to specified version
--- @cons VCompatible - semver arrow, version must be larger or equal and within same minor version
--- @cons VCompatible - semver arrow, version must be larger or equal and
--- within same minor version
data VersionConstraint = VExact Version
| VGt Version
| VLt Version
......@@ -240,7 +242,13 @@ dependencyNames p = map (\(Dependency s _) -> s) $ dependencies p
--- Renders a dependency as a string, including all version constraints.
showDependency :: Dependency -> String
showDependency (Dependency p vcs) = p ++ (showVersionConstraints vcs)
showDependency (Dependency p vcs) = p ++ showVersionConstraints vcs
--- Renders a compiler dependency as a string, including all version
--- constraints.
showCompilerDependency :: CompilerCompatibility -> String
showCompilerDependency (CompilerCompatibility cc vcs) =
cc ++ showVersionConstraints vcs
--- Renders a list of version constraints in disjunctive normal form.
showVersionConstraints :: [[VersionConstraint]] -> String
......@@ -251,11 +259,11 @@ showDisjunction = intercalate " || " . map (intercalate ", " . map showVersionCo
--- Renders a single version constraint as a string.
showVersionConstraint :: VersionConstraint -> String
showVersionConstraint (VLt v) = " < " ++ (showVersion v)
showVersionConstraint (VLte v) = " <= " ++ (showVersion v)
showVersionConstraint (VGt v) = " > " ++ (showVersion v)
showVersionConstraint (VGte v) = " >= " ++ (showVersion v)
showVersionConstraint (VExact v) = " = " ++ (showVersion v)
showVersionConstraint (VLt v) = " < " ++ (showVersion v)
showVersionConstraint (VLte v) = " <= " ++ (showVersion v)
showVersionConstraint (VGt v) = " > " ++ (showVersion v)
showVersionConstraint (VGte v) = " >= " ++ (showVersion v)
showVersionConstraint (VExact v) = " = " ++ (showVersion v)
showVersionConstraint (VCompatible v) = " ~> " ++ (showVersion v)
--- Renders the id of a package as a string. Package name and version separated
......
......@@ -237,7 +237,7 @@ checkoutPackage cfg _ _ pkg = do
else log Info $ "Package '" ++ pkgId ++ "' is not installed."
where
pkgDir = (packageInstallDir cfg) </> pkgId
pkgId = name pkg ++ "-" ++ showVersion (version pkg)
pkgId = packageId pkg
logMsg = "Package '" ++ pkgId ++ "' checked out into local directory."
--- Removes a package from the global package cache.
......
......@@ -36,10 +36,10 @@ import CPM.ErrorLogger
import qualified CPM.PackageCache.Global as GC
import qualified CPM.PackageCache.Runtime as RuntimeCache
import qualified CPM.PackageCache.Local as LocalCache
import CPM.Package (Package (source, version, author, synopsis, dependencies
, description, name, exportedModules)
import CPM.Package ( Package (..)
, readPackageSpec, packageId, readVersion, Version
, showVersion, PackageSource (..), showDependency
, showCompilerDependency
, Dependency, GitRevision (..), packageIdEq, loadPackageSpec)
import CPM.Resolution
import CPM.FileUtil (copyDirectory, recreateDirectory)
......@@ -195,11 +195,16 @@ renderPackageInfo :: Bool -> Repository -> GC.GlobalCache -> Package -> String
renderPackageInfo allinfos _ gc pkg = pPrint doc
where
maxLen = 12
doc = vcat $ [heading, rule, installed, ver, auth, synop, deps, descr] ++
if allinfos then [expmods, src] else []
doc = vcat $ [ heading, rule, installed, ver, auth, maintnr, synop
, deps, compilers, descr ] ++
if allinfos
then [expmods, src, licns, copyrt, homepg, reposy, bugrep]
else []
pkgId = packageId pkg
isInstalled = GC.isPackageInstalled gc pkg
heading = text pkgId
heading = text pkgId
installed = if isInstalled then empty else red $ text "Not installed"
rule = text (take (length pkgId) $ repeat '-')
ver = fill maxLen (bold (text "Version")) <+>
......@@ -209,23 +214,42 @@ renderPackageInfo allinfos _ gc pkg = pPrint doc
deps = (bold $ text "Dependencies") <$$>
(vcat $ map (indent 4 . text . showDependency) $ dependencies pkg)
descr = case description pkg of
maintnr = case maintainer pkg of
Nothing -> empty
Just d -> (bold $ text "Description") <$$>
(indent 4 (fillSep (map text (words d))))
Just s -> fill maxLen (bold (text "Maintainer")) <+> text s
descr = showParaField description "Description"
licns = showParaField license "License"
copyrt = showParaField copyright "Copyright"
homepg = showLineField homepage "Homepage"
reposy = showLineField repository "Repository"
bugrep = showLineField bugReports "Bug reports"
src = case source pkg of
Nothing -> empty
Just (Http s) -> (bold $ text "Source") <$$>
(indent 4 (text s))
Just (Git s _) -> (bold $ text "Source") <$$>
(indent 4 (text s))
Just (FileSource s) -> (bold $ text "Source") <$$>
(indent 4 (text s))
Nothing -> empty
Just (Http s) -> bold (text "Source") <$$> indent 4 (text s)
Just (Git s _) -> bold (text "Source") <$$> indent 4 (text s)
Just (FileSource s) -> bold (text "Source") <$$> indent 4 (text s)
expmods =
if null (exportedModules pkg)
then empty
else (bold $ text "Exported modules") <$$>
(indent 4 (fillSep (map text (exportedModules pkg))))
else bold (text "Exported modules") <$$>
indent 4 (fillSep (map text (exportedModules pkg)))
compilers =
if null (compilerCompatibility pkg)
then empty
else bold (text "Compiler compatibility") <$$>
(vcat $ map (indent 4 . text . showCompilerDependency)
$ compilerCompatibility pkg)
showLineField fgetter fname = case fgetter pkg of
Nothing -> empty
Just s -> bold (text fname) <$$> indent 4 (text s)
showParaField fgetter fname = case fgetter pkg of
Nothing -> empty
Just s -> bold $ text fname <$$>
indent 4 (fillSep (map text (words s)))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment