aboutsummaryrefslogtreecommitdiff
path: root/clpm.icl
diff options
context:
space:
mode:
Diffstat (limited to 'clpm.icl')
-rw-r--r--clpm.icl44
1 files changed, 35 insertions, 9 deletions
diff --git a/clpm.icl b/clpm.icl
index dab9e83..ad627fa 100644
--- a/clpm.icl
+++ b/clpm.icl
@@ -24,6 +24,7 @@ import System.Directory
import System.File
import CLPM.Package
+import CLPM.Repository
:: Action
= NoAction
@@ -33,6 +34,8 @@ import CLPM.Package
:: Arguments
= { package_file :: String
, action :: Action
+ , repository :: String
+ , clm_options :: [String]
}
instance zero Arguments
@@ -40,6 +43,8 @@ where
zero
= { package_file = PACKAGE_FILE
, action = NoAction
+ , repository = REPOSITORY
+ , clm_options = []
}
Start w
@@ -50,11 +55,11 @@ Start w
# (_,w) = fclose io w
= w
# (pkg,w) = readPackage args.package_file w
-| isNothing pkg
- # io = io <<< "Could not parse " <<< args.package_file <<< '\n'
+| isError pkg
+ # io = io <<< fromError pkg <<< "\n"
# (_,w) = fclose io w
= w
-# pkg = fromJust pkg
+# (Ok pkg) = pkg
# (io,w) = do args pkg io w
# (_,w) = fclose io w
= w
@@ -63,24 +68,41 @@ do :: Arguments Package *File *World -> *(*File, *World)
do args pkg io w = case args.action of
NoAction = (io,w)
Install = install pkg io w
- Make = make pkg io w
+ Make = make args.clm_options pkg io w
install :: Package *File *World -> *(*File, *World)
install pkg io w
# (e,w) = fileExists MODULE_DIR w
# w = if e w (snd $ createDirectory MODULE_DIR w)
-# (r,w) = syscall "echo hello" w
-# io = io <<< r <<< "\n"
+# (repo,w) = getRepository REPOSITORY w
+| isError repo
+ = (io <<< fromError repo <<< "\n", w)
+# (Ok repo) = repo
+# io = foldl printRepo io repo
+# solv = resolveDependencies repo pkg
+| isError solv
+ = (io <<< fromError solv <<< "\n", w)
+# (Ok solv) = solv
+# io = io <<< "Dependencies:\n"
+# io = printDeps io solv
= (io,w)
+where
+ printRepo :: *File RepositoryItem -> *File
+ printRepo f ri = f <<< ri.RepositoryItem.name <<< "\t" <<<
+ foldl (+++) "" [toString v.RepositoryItemVersion.version + ", " \\ v <- ri.RepositoryItem.versions]
+ <<< "\n"
+
+ printDeps :: *File [(Dependency, Version)] -> *File
+ printDeps f ds = foldl (<<<) f [depName d + "\t" + toString v + "\n" \\ (d,v) <- ds]
-make :: Package *File *World -> *(*File, *World)
-make pkg io w
+make :: [String] Package *File *World -> *(*File, *World)
+make opts pkg io w
# (ps,w) = getRecursivePaths pkg w
| isError ps
= (io <<< fromError ps <<< "\n", w)
# ps = fromOk ps
# (r,w) = syscall (foldl (+) "clm" [" -I " + p \\ p <- ps] +
- foldl (+) "" [" " + f \\ f <- optionsToFlags pkg.options] +
+ foldl (+) "" [" " + f \\ f <- optionsToFlags pkg.options ++ opts] +
" " + pkg.main + " -o " + pkg.main) w
= (io,w)
@@ -89,6 +111,10 @@ parseArgs miss args []
= (miss, args)
parseArgs miss args ["-p":name:rest]
= parseArgs miss {args & package_file = name} rest
+parseArgs miss args ["-r":repo:rest]
+ = parseArgs miss {args & repository = repo} rest
+parseArgs miss args ["-c":opt:rest]
+ = parseArgs miss {args & clm_options = args.clm_options ++ [opt]} rest
parseArgs miss args ["install":rest]
= parseArgs miss {args & action = Install} rest
parseArgs miss args ["make":rest]