aboutsummaryrefslogtreecommitdiff
path: root/clpm.icl
diff options
context:
space:
mode:
Diffstat (limited to 'clpm.icl')
-rw-r--r--clpm.icl59
1 files changed, 27 insertions, 32 deletions
diff --git a/clpm.icl b/clpm.icl
index 26b98f4..a3382d1 100644
--- a/clpm.icl
+++ b/clpm.icl
@@ -26,6 +26,7 @@ import System.File
import CLPM.Package
import CLPM.Repository
+import CLPM.Util
CLPM_VERSION :== (0,1,0)
@@ -37,7 +38,7 @@ CLPM_VERSION :== (0,1,0)
:: Arguments
= { package_file :: String
, action :: Action
- , repository :: String
+ //, repository :: String
, clm_options :: [String]
, show_help :: Bool
}
@@ -47,7 +48,7 @@ where
zero
= { package_file = PACKAGE_FILE
, action = NoAction
- , repository = REPOSITORY
+ //, repository = REPOSITORY
, clm_options = []
, show_help = False
}
@@ -56,13 +57,13 @@ Start w
# (io,w) = stdio w
# ((missed, args), w) = appFst (parseArgs zero o tl) $ getCommandLine w
| not (isEmpty missed)
- # io = foldr (flip (<<<)) io ["Unknown option: " + m + "\n" \\ m <- missed]
+ # io = foldr (flip (<<<)) io ["Unknown option: " + m + "\r\n" \\ m <- missed]
= snd $ fclose io w
| args.show_help
= snd $ fclose (io <<< HELP_TEXT) w
# (pkg,w) = readPackage args.package_file w
| isError pkg
- # io = io <<< fromError pkg <<< "\n"
+ # io = io <<< fromError pkg <<< "\r\n"
# (_,w) = fclose io w
= w
# (Ok pkg) = pkg
@@ -73,39 +74,38 @@ Start w
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 args.clm_options pkg io w
+ Install = cmd_install pkg io w
+ Make = cmd_make args.clm_options pkg io w
-install :: Package *File *World -> *(*File, *World)
-install pkg io w
+cmd_install :: Package *File *World -> *(*File, *World)
+cmd_install pkg io w
# (e,w) = fileExists MODULE_DIR w
# w = if e w (snd $ createDirectory MODULE_DIR w)
# (repo,w) = getRepository REPOSITORY w
| isError repo
- = (io <<< fromError repo <<< "\n", w)
+ = (io <<< fromError repo <<< "\r\n", w)
# (Ok repo) = repo
-# io = foldl printRepo io repo
# solv = resolveDependencies repo pkg
| isError solv
- = (io <<< fromError solv <<< "\n", w)
+ = (io <<< fromError solv <<< "\r\n", w)
# (Ok solv) = solv
-# io = io <<< "Dependencies:\n"
-# io = printDeps io solv
+# io = io <<< "Installing dependencies:\r\n"
+# (io,w) = installAll solv io w
= (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 :: [String] Package *File *World -> *(*File, *World)
-make opts pkg io w
+ installAll :: [(Dependency, Version)] *File *World -> *(*File, *World)
+ installAll [] f w = (f,w)
+ installAll [(d,v):ds] f w
+ # f = f <<< "Installing " <<< depName d <<< ":" <<< toString v <<< "...\r\n"
+ # (err,w) = install d v w
+ | isError err = (f <<< fromError err <<< "\r\n", w)
+ = installAll ds f w
+
+cmd_make :: [String] Package *File *World -> *(*File, *World)
+cmd_make opts pkg io w
# (ps,w) = getRecursivePaths pkg w
| isError ps
- = (io <<< fromError ps <<< "\n", w)
+ = (io <<< fromError ps <<< "\r\n", w)
# ps = fromOk ps
# (r,w) = syscall (foldl (+) "clm" [" -I " + p \\ p <- ps] +
foldl (+) "" [" " + f \\ f <- optionsToFlags pkg.options ++ opts] +
@@ -120,17 +120,12 @@ where
pa miss args ["-h":rest] = pa miss {args & show_help = True} rest
pa miss args ["--help":rest] = pa miss {args & show_help = True} rest
pa miss args ["-p":name:rest] = pa miss {args & package_file = name} rest
- pa miss args ["-r":repo:rest] = pa miss {args & repository = repo} rest
+ //pa miss args ["-r":repo:rest] = pa miss {args & repository = repo} rest
pa miss args ["-c":opt:rest] = pa miss {args & clm_options = args.clm_options ++ [opt]} rest
pa miss args ["install":rest] = pa miss {args & action = Install} rest
pa miss args ["make":rest] = pa miss {args & action = Make} rest
pa miss args [a:rest] = pa [a:miss] args rest
-syscall :: !String !*World -> !*(!Int, !*World)
-syscall cmd w = code {
- ccall system "s:I:A"
-}
-
HELP_TEXT =:
"CLPM - A Clean Package Manager - v" + toString CLPM_VERSION + "\r\n\r\n" +
"Usage: clpm <command> [option]\r\n\r\n" +
@@ -151,8 +146,8 @@ where
"Print this help text")
, ("-p <FILE>",
"Use FILE as package file instead of package.json")
- , ("-r <HOST>",
- "Use HOST as repository provider instead of " + REPOSITORY)
+ //, ("-r <HOST>",
+ // "Use HOST as repository provider instead of " + REPOSITORY)
]
pad :: Int Int String -> String