Commit 7489698e authored by Valentin Reis's avatar Valentin Reis

Commandline argument update, file split.

parent d8ed280d
Pipeline #4731 passed with stage
in 40 seconds
......@@ -11,6 +11,7 @@ cabal-version: >=1.10
library
exposed-Modules: Argo.Stack
Argo.Utils
Argo.Args
build-depends: base >=4 && <=8, turtle, data-default, managed, ansi-terminal, unix, system-filepath, async, process, text, optparse-applicative, extra, foldl, conduit,conduit-extra, bytestring
hs-source-dirs: src
default-language: Haskell2010
module Argo
( module Argo.Stack
( module Argo.Args
, module Argo.Utils
)
where
import Argo.Stack
import Argo.Utils
import Argo.Args
{-# LANGUAGE
OverloadedStrings,
ApplicativeDo,
RecordWildCards #-}
module Argo.Args where
import Options.Applicative as OA
import Data.Default
import Data.Text as T
hiding ( empty )
import Turtle
import Prelude hiding ( FilePath )
data StackArgs = StackArgs
{ app :: Text
, args :: [Text]
, containerName :: Text
, workingDirectory :: FilePath
, manifestDir :: FilePath
, manifestName :: FilePath
, cmd_out :: FilePath
, cmd_err :: FilePath
, daemon_out :: FilePath
, daemon_err :: FilePath
, nrm_log :: FilePath
, messageDaemonOut :: Maybe Text
, messageDaemonErr :: Maybe Text
, messageCmdOut :: Maybe Text
, messageCmdErr :: Maybe Text
}
instance Default StackArgs where
def = StackArgs
{ app = "echo"
, args = ["foobar"]
, containerName = "testContainer"
, workingDirectory = "_output"
, manifestDir = "manifests"
, manifestName = "basic.json"
, cmd_out = "cmd_out.log"
, cmd_err = "cmd_err.log"
, daemon_out = "daemon_out.log"
, daemon_err = "daemon_err.log"
, nrm_log = "nrm.log"
, messageDaemonOut = Nothing
, messageDaemonErr = Nothing
, messageCmdOut = Nothing
, messageCmdErr = Nothing
}
parseExtendStackArgs :: StackArgs -> Parser StackArgs
parseExtendStackArgs StackArgs {..} = do
app <- strOption
( long "application"
<> metavar "APP"
<> help "Target application executable name. PATH is inherited."
<> showDefault
<> value app
)
containerName <- strOption
( long "container_name"
<> metavar "ARGO_CONTAINER_UUID"
<> help "Container name"
<> showDefault
<> value containerName
)
workingDirectory <- strOption
( long "output"
<> metavar "FILE"
<> help "Working directory."
<> showDefault
<> value workingDirectory
)
manifestDir <- strOption
( long "manifest_directory"
<> metavar "FILE"
<> help "Manifest lookup directory"
<> showDefault
<> value manifestDir
)
manifestName <- strOption
( long "manifest_name"
<> metavar "FILE"
<> help "Manifest basename"
<> showDefault
<> value manifestName
)
cmd_out <- strOption
( long "cmd_out"
<> metavar "FILE"
<> help "Output file, application stdout"
<> showDefault
<> value cmd_out
)
cmd_err <- strOption
( long "cmd_err"
<> metavar "FILE"
<> help "Output file, application stderr"
<> showDefault
<> value cmd_err
)
daemon_out <- strOption
( long "daemon_out"
<> metavar "FILE"
<> help "Output file, daemon stdout"
<> showDefault
<> value daemon_out
)
daemon_err <- strOption
( long "daemon_err"
<> metavar "FILE"
<> help "Output file, daemon stderr"
<> showDefault
<> value daemon_err
)
nrm_log <- strOption
( long "nrm_log"
<> metavar "FILE"
<> help "Output file, daemon log"
<> showDefault
<> value nrm_log
)
messageDaemonOut <- optional $ strOption
( long "message_daemon_stdout"
<> metavar "STRING"
<> help
"The appearance of this character string in the daemon stdout \
\ will be monitored during execution and the stack will be \
\ killed when observing it, returning a successful exit code."
<> showDefault
<> maybe mempty value messageDaemonOut
)
messageDaemonErr <- optional $ strOption
( long "message_daemon_stderr"
<> metavar "STRING"
<> help
"The appearance of this character string in the daemon stderr \
\ will be monitored during execution and the stack will be \
\ killed when observing it, returning a successful exit code."
<> showDefault
<> maybe mempty value messageDaemonErr
)
messageCmdOut <- optional $ strOption
( long "message_cmd_stdout"
<> metavar "STRING"
<> help
"The appearance of this character string in the cmd stdout \
\ will be monitored during execution and the stack will be \
\ killed when observing it, returning a successful exit code."
<> showDefault
<> maybe mempty value messageCmdOut
)
messageCmdErr <- optional $ strOption
( long "message_cmd_stderr"
<> metavar "STRING"
<> help
"The appearance of this character string in the cmd stderr \
\ will be monitored during execution and the stack will be \
\ killed when observing it, returning a successful exit code."
<> showDefault
<> maybe mempty value messageCmdErr
)
pure StackArgs {..}
......@@ -8,8 +8,8 @@
ApplicativeDo #-}
module Argo.Stack where
import Argo.Args
import Data.Default
import Turtle
import Turtle.Shell
import Prelude hiding ( FilePath )
......@@ -37,156 +37,6 @@ import Data.ByteString.Char8 as C8
import Control.Exception.Base
import Data.Maybe
data StackArgs = StackArgs
{ app :: Text
, args :: [Text]
, containerName :: Text
, workingDirectory :: FilePath
, manifestDir :: FilePath
, manifestName :: FilePath
, cmd_out :: FilePath
, cmd_err :: FilePath
, daemon_out :: FilePath
, daemon_err :: FilePath
, nrm_log :: FilePath
, messageDaemonOut :: Maybe Text
, messageDaemonErr :: Maybe Text
, messageCmdOut :: Maybe Text
, messageCmdErr :: Maybe Text
}
instance Default StackArgs where
def = StackArgs
{ app = "echo"
, args = ["foobar"]
, containerName = "testContainer"
, workingDirectory = "_output"
, manifestDir = "manifests"
, manifestName = "basic.json"
, cmd_out = "cmd_out.log"
, cmd_err = "cmd_err.log"
, daemon_out = "daemon_out.log"
, daemon_err = "daemon_err.log"
, nrm_log = "nrm.log"
, messageDaemonOut = Nothing
, messageDaemonErr = Nothing
, messageCmdOut = Nothing
, messageCmdErr = Nothing
}
parseExtendStackArgs :: StackArgs -> Parser StackArgs
parseExtendStackArgs StackArgs {..} = do
app <- strOption
( long "application"
<> metavar "APP"
<> help "Target application executable name. PATH is inherited."
<> showDefault
<> value app
)
containerName <- strOption
( long "container_name"
<> metavar "ARGO_CONTAINER_UUID"
<> help "Container name"
<> showDefault
<> value containerName
)
workingDirectory <- strOption
( long "output"
<> metavar "FILE"
<> help "Working directory."
<> showDefault
<> value workingDirectory
)
manifestDir <- strOption
( long "manifest_directory"
<> metavar "FILE"
<> help "Manifest lookup directory"
<> showDefault
<> value manifestDir
)
manifestName <- strOption
( long "manifest_name"
<> metavar "FILE"
<> help "Manifest basename"
<> showDefault
<> value manifestName
)
cmd_out <- strOption
( long "cmd_out"
<> metavar "FILE"
<> help "Output file, application stdout"
<> showDefault
<> value cmd_out
)
cmd_err <- strOption
( long "cmd_err"
<> metavar "FILE"
<> help "Output file, application stderr"
<> showDefault
<> value cmd_err
)
daemon_out <- strOption
( long "daemon_out"
<> metavar "FILE"
<> help "Output file, daemon stdout"
<> showDefault
<> value daemon_out
)
daemon_err <- strOption
( long "daemon_err"
<> metavar "FILE"
<> help "Output file, daemon stderr"
<> showDefault
<> value daemon_err
)
nrm_log <- strOption
( long "nrm_log"
<> metavar "FILE"
<> help "Output file, daemon log"
<> showDefault
<> value nrm_log
)
messageDaemonOut <- optional $ strOption
( long "message_daemon_stdout"
<> metavar "STRING"
<> help
"The appearance of this character string in the daemon stdout \
\ will be monitored during execution and the stack will be \
\ killed when observing it, returning a successful exit code."
<> showDefault
<> maybe mempty value messageDaemonOut
)
messageDaemonErr <- optional $ strOption
( long "message_daemon_stdout"
<> metavar "STRING"
<> help
"The appearance of this character string in the daemon stderr \
\ will be monitored during execution and the stack will be \
\ killed when observing it, returning a successful exit code."
<> showDefault
<> maybe mempty value messageDaemonErr
)
messageCmdOut <- optional $ strOption
( long "message_daemon_stdout"
<> metavar "STRING"
<> help
"The appearance of this character string in the cmd stdout \
\ will be monitored during execution and the stack will be \
\ killed when observing it, returning a successful exit code."
<> showDefault
<> maybe mempty value messageCmdOut
)
messageCmdErr <- optional $ strOption
( long "message_daemon_stdout"
<> metavar "STRING"
<> help
"The appearance of this character string in the cmd stderr \
\ will be monitored during execution and the stack will be \
\ killed when observing it, returning a successful exit code."
<> showDefault
<> maybe mempty value messageCmdErr
)
pure StackArgs {..}
cleanLeftoverProcesses :: Shell ()
cleanLeftoverProcesses = do
......
......@@ -4,6 +4,7 @@
import Argo.Stack
import Argo.Utils
import Argo.Args
import Turtle
import Prelude hiding ( FilePath )
import Data.Default
......
......@@ -98,8 +98,8 @@ in rec
amg
nrm
(hpkgs.ghcWithPackages (p: devHPackages ++ [
argotk
argo
argotk
argo
(pkgs.haskell.lib.doJailbreak p.panpipe)
p.turtle]))
];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment