@@ -11,28 +11,27 @@ import qualified Data.Text.Lazy.Builder as TL
1111import qualified Data.Text.Lazy.Encoding as TL
1212import Distribution.Compiler (CompilerFlavor (..))
1313import Language.Haskell.Extension (Extension (..))
14−import System.Environment (getArgs)
1514import System.IO (IOMode (..), hClose, hPutStrLn, openFile, stderr)
1615import System.FilePath (hasTrailingPathSeparator, joinPath, normalise, splitPath)
1716
1817import Obelisk.Command.Run (CabalPackageInfo (..), parseCabalPackage')
1918
20−main :: IO ()
21−main = do
22− -- The command line argumens are passed in via ghci.
23− -- ghci dictates the first three options and meanings
24− -- TODO: perform some validation and print a nice error/help message, if we don't see something plausible.
19+applyPackages :: FilePath -> FilePath -> FilePath -> [FilePath] -> IO ()
20+applyPackages origPath inPath outPath packagePaths = do
21+ -- This code is intended to be executed via ghci's -pgmF preprocessor option
22+ -- The command line arguments are passed in via ghc, which dictates the first three options and meanings
23+ -- In order for this code to execute, origPath must contain either a '.' character or a '/' character.
24+ -- (This is to avoid the possibility of the command line syntax conflicting with another ob command)
2525 -- We do have control over the remaining arguments, but they must be the same for all files.
26+ -- Thus, the fourth command line argument must be "apply-packages", which has already been handled.
2627 -- We assume all the remaining arguments passed in are paths to cabal or hpack package specifications.
2728
28− args@(origPath:inPath:outPath:packagePaths) <- getArgs
29−
3029 outFile <- openFile outPath WriteMode
3130 let hPutTextBuilder h = BU.hPutBuilder h . TL.encodeUtf8Builder . TL.toLazyText
3231
33− putStr "--------------------------------------------------------------------------------\n"
34− print args
35− putStr "--------------------------------------------------------------------------------\n"
32+ -- putStr "--------------------------------------------------------------------------------\n"
33+ -- print args
34+ -- putStr "--------------------------------------------------------------------------------\n"
3635
3736 -- Thus we must select among the packagePaths for the file we are going to parse.
3837