aboutsummaryrefslogtreecommitdiff
path: root/clpm.icl
diff options
context:
space:
mode:
authorCamil Staps2017-02-04 17:06:34 +0100
committerCamil Staps2017-02-04 17:06:34 +0100
commit9e5cf667a4d99bbeb2506da94e8f3252f0bd9236 (patch)
treee7fac889e0e07d262750045bcdf453c6205a2e64 /clpm.icl
parentBasic Package structure (diff)
Working make command
Diffstat (limited to 'clpm.icl')
-rw-r--r--clpm.icl51
1 files changed, 45 insertions, 6 deletions
diff --git a/clpm.icl b/clpm.icl
index 195b135..dab9e83 100644
--- a/clpm.icl
+++ b/clpm.icl
@@ -5,32 +5,41 @@ import StdFile
import StdList
import StdOverloaded
import StdString
+import StdTuple
import Control.Applicative
import Control.Monad
+
import Data.Error
from Data.Func import $
import Data.Functor
import Data.Maybe
import Data.Tuple
+
from Text import instance + String
import Text.JSON
import System.CommandLine
+import System.Directory
import System.File
import CLPM.Package
-FILENAME :== "clpm.json"
+:: Action
+ = NoAction
+ | Install
+ | Make
:: Arguments
= { package_file :: String
+ , action :: Action
}
instance zero Arguments
where
zero
- = { package_file = FILENAME
+ = { package_file = PACKAGE_FILE
+ , action = NoAction
}
Start w
@@ -46,18 +55,48 @@ Start w
# (_,w) = fclose io w
= w
# pkg = fromJust pkg
-# io = io <<< pkg <<< '\n'
+# (io,w) = do args pkg io w
# (_,w) = fclose io w
= 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 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"
+= (io,w)
+
+make :: Package *File *World -> *(*File, *World)
+make 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] +
+ " " + pkg.main + " -o " + pkg.main) w
+= (io,w)
+
parseArgs :: [String] Arguments [String] -> ([String], Arguments)
parseArgs miss args []
= (miss, args)
parseArgs miss args ["-p":name:rest]
= parseArgs miss {args & package_file = name} rest
+parseArgs miss args ["install":rest]
+ = parseArgs miss {args & action = Install} rest
+parseArgs miss args ["make":rest]
+ = parseArgs miss {args & action = Make} rest
parseArgs miss args [a:rest]
= parseArgs [a:miss] args rest
-readPackage :: String -> *World -> *(Maybe Package, *World)
-readPackage f = appFst parse o readFile f
-where parse = join o fmap (fmap toPackage o fromJSON o fromString) o error2mb
+syscall :: !String !*World -> !*(!Int, !*World)
+syscall cmd w = code {
+ ccall system "s:I:A"
+}