diff --git a/argotest/src/Argotest.hs b/argotest/src/Argotest.hs index 3a650738f9faf3dbda384c8821804f337f807cf6..7a20a6cab2465e128aa45f3921aaa4326b9f457d 100644 --- a/argotest/src/Argotest.hs +++ b/argotest/src/Argotest.hs @@ -23,7 +23,7 @@ import Data.Text as Text hiding (empty) import Data.Text.IO as Text data StackArgs = StackArgs - { dargs :: [Text] --"Daemon arguments. Properly quote this." + { dargs :: [Text] --"Daemon arguments. Properly quote this." , app :: Text --"Target application call, sh+path valid" , manifest :: FilePath --"Input file, manifest." , cmd_out :: FilePath --"Output file, application stdout" @@ -37,7 +37,7 @@ instance Default StackArgs where def = StackArgs { dargs = [] , app = "echo \"HelloWorld\"" - , manifest = "manifests/basic.json" + , manifest = "basic.json" , cmd_out = "cmd_out.log" , cmd_err = "cmd_err.log" , daemon_out = "daemon_out.log" diff --git a/argotk.hs b/argotk.hs index 9f3a234cb7ee01aa9f02cff7f980e3522e53be6c..a72cc044523ba3166ff8f3f106e5840156277ed9 100755 --- a/argotk.hs +++ b/argotk.hs @@ -9,32 +9,37 @@ import Argotest import Turtle import Data.Default import Control.Concurrent.Async +import System.Environment import System.Console.ANSI import System.Console.ANSI.Types (Color) import Options.Applicative import System.Posix.Signals import Control.Monad +import System.Environment.FindBin -opts :: Parser (IO ()) -opts = subparser - ( command "clean" (info (pure $ runClean def) +opts :: StackArgs -> Parser (IO ()) +opts sa = subparser + ( command "clean" (info (pure $ runClean sa) (progDesc "Clean sockets, logfiles.")) - <> command "daemon" (info (pure $ runDaemon def) + <> command "daemon" (info (pure $ runDaemon sa) (progDesc "Set up and launch the daemon in synchronous mode, \ \with properly cleaned sockets, logfiles.")) - <> command "application" (info (runApp <$> argument str idm) + <> command "application" (info (runApp sa <$> argument str idm) (progDesc "Setup stack and run an arbitrary command in a container.")) - <> command "helloworld" (info (pure $ runHelloWorld def ) + <> command "helloworld" (info (pure $ runHelloWorld sa ) (progDesc "Setup stack and check that hello world app sends \ \message back to cmd.")) <> help "Type of action to run" ) main :: IO () -main = join $ execParser (info (opts <**>helper) idm) +main = do + manifests <- getEnv "MANIFESTS" + let sa = def { manifest = decodeString manifests manifest def} + join $ execParser (info (opts sa <**>helper) idm) -runApp :: Text -> IO () -runApp app = runSimpleStack $ def {app = app} +runApp :: StackArgs -> Text -> IO () +runApp sa app = runSimpleStack $ sa {app = app} runHelloWorld :: StackArgs -> IO () runHelloWorld a@StackArgs{..} = do diff --git a/default.nix b/default.nix index 97c95300d7af4d7731abb7d62dab65f90ff5e056..4f1ba3ab6d76a79c9009265ead5ad494a413e189 100644 --- a/default.nix +++ b/default.nix @@ -43,6 +43,7 @@ in rec p.unix p.system-filepath p.async + p.FindBin (pkgs.haskell.lib.doJailbreak p.panpipe) ])) containers @@ -52,6 +53,7 @@ in rec amg nrm ]; + MANIFESTS = ./manifests; }; test = pkgs.stdenv.mkDerivation rec { @@ -62,11 +64,12 @@ in rec name = "env"; env = pkgs.buildEnv { name = name; paths = buildInputs; }; buildInputs = [ - (hpkgs.ghcWithPackages (p: [p.argotest])) + (hpkgs.ghcWithPackages (p: [p.argotest p.FindBin])) containers amg nrm ]; + MANIFESTS = ./manifests; }; }