mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 03:32:51 -06:00
transferc now uses env var TRANSFER_PATH to locate imports.
This commit is contained in:
@@ -12,14 +12,28 @@ die s = do
|
|||||||
hPutStrLn stderr s
|
hPutStrLn stderr s
|
||||||
exitFailure
|
exitFailure
|
||||||
|
|
||||||
|
getPath :: IO [String]
|
||||||
|
getPath = do env <- getEnvironment
|
||||||
|
return $ case lookup "TRANSFER_PATH" env of
|
||||||
|
Nothing -> []
|
||||||
|
Just p -> splitBy (==':') p
|
||||||
|
|
||||||
|
-- Modified version of a function which is originally
|
||||||
|
-- Copyright Bryn Keller
|
||||||
|
splitBy :: (a -> Bool) -> [a] -> [[a]]
|
||||||
|
splitBy _ [] = []
|
||||||
|
splitBy f list = first : splitBy f (dropWhile f rest)
|
||||||
|
where (first, rest) = break f list
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
args <- getArgs
|
args <- getArgs
|
||||||
let (flags,files) = partition ("-" `isPrefixOf`) args
|
let (flags,files) = partition ("-" `isPrefixOf`) args
|
||||||
path = [ p | ('-':'i':p) <- flags ]
|
argPath = [ p | ('-':'i':p) <- flags ]
|
||||||
|
envPath <- getPath
|
||||||
case files of
|
case files of
|
||||||
[f] -> do
|
[f] -> do
|
||||||
cf <- compileFile path f
|
cf <- compileFile (argPath ++ envPath) f
|
||||||
putStrLn $ "Wrote " ++ cf
|
putStrLn $ "Wrote " ++ cf
|
||||||
return ()
|
return ()
|
||||||
_ -> die "Usage: transferc [-i<path> [-i<path> ... ]] <file>"
|
_ -> die "Usage: transferc [-i<path> [-i<path> ... ]] <file>"
|
||||||
|
|||||||
Reference in New Issue
Block a user