Make arion repl work
This commit is contained in:
parent
b9488b7f49
commit
fcf270c80c
3 changed files with 38 additions and 6 deletions
|
@ -70,9 +70,9 @@ textArgument = fmap T.pack . strArgument
|
||||||
parseCommand :: Parser (CommonOptions -> IO ())
|
parseCommand :: Parser (CommonOptions -> IO ())
|
||||||
parseCommand =
|
parseCommand =
|
||||||
hsubparser
|
hsubparser
|
||||||
( command "cat" (info (pure runCat) (progDesc "TODO: cat doc" <> fullDesc))
|
( command "cat" (info (pure runCat) (progDesc "Spit out the docker compose file as JSON" <> fullDesc))
|
||||||
<> command "repl" (info (pure runRepl) (progDesc "TODO: repl doc" <> fullDesc))
|
<> command "repl" (info (pure runRepl) (progDesc "Start a nix repl for the whole composition" <> fullDesc))
|
||||||
<> command "exec" (info (pure runExec) (progDesc "TODO: exec doc" <> fullDesc))
|
-- <> command "exec" (info (pure runExec) (progDesc "TODO: exec doc" <> fullDesc))
|
||||||
)
|
)
|
||||||
<|>
|
<|>
|
||||||
hsubparser
|
hsubparser
|
||||||
|
@ -172,8 +172,18 @@ runCat co = do
|
||||||
T.hPutStrLn stdout (pretty v)
|
T.hPutStrLn stdout (pretty v)
|
||||||
|
|
||||||
runRepl :: CommonOptions -> IO ()
|
runRepl :: CommonOptions -> IO ()
|
||||||
runRepl opts =
|
runRepl co = do
|
||||||
T.putStrLn "Running repl ... TODO"
|
putErrText
|
||||||
|
"Launching a repl for you. To get started:\n\
|
||||||
|
\\n\
|
||||||
|
\To see deployment-wide configuration\n\
|
||||||
|
\ type config. and hit TAB\n\
|
||||||
|
\To see the services\n\
|
||||||
|
\ type config.docker-compose.evaluatedServices TAB or ENTER\n\
|
||||||
|
\To bring the top-level Nixpkgs attributes into scope\n\
|
||||||
|
\ type :a (config._module.args.pkgs) // { inherit config; }\n\
|
||||||
|
\"
|
||||||
|
Arion.Nix.replForComposition =<< defaultEvaluationArgs co
|
||||||
|
|
||||||
runExec :: CommonOptions -> IO ()
|
runExec :: CommonOptions -> IO ()
|
||||||
runExec opts =
|
runExec opts =
|
||||||
|
|
|
@ -40,7 +40,6 @@ run args = do
|
||||||
|
|
||||||
withCreateProcess procSpec $ \_in _out _err procHandle -> do
|
withCreateProcess procSpec $ \_in _out _err procHandle -> do
|
||||||
|
|
||||||
-- Wait for process exit and 'err' printout
|
|
||||||
exitCode <- waitForProcess procHandle
|
exitCode <- waitForProcess procHandle
|
||||||
|
|
||||||
case exitCode of
|
case exitCode of
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
module Arion.Nix
|
module Arion.Nix
|
||||||
( evaluateComposition
|
( evaluateComposition
|
||||||
, withEvaluatedComposition
|
, withEvaluatedComposition
|
||||||
|
, buildComposition
|
||||||
, withBuiltComposition
|
, withBuiltComposition
|
||||||
|
, replForComposition
|
||||||
, EvaluationArgs(..)
|
, EvaluationArgs(..)
|
||||||
, EvaluationMode(..)
|
, EvaluationMode(..)
|
||||||
) where
|
) where
|
||||||
|
@ -137,6 +139,27 @@ withBuiltComposition ea f = do
|
||||||
buildComposition path ea
|
buildComposition path ea
|
||||||
f path
|
f path
|
||||||
|
|
||||||
|
|
||||||
|
replForComposition :: EvaluationArgs -> IO ()
|
||||||
|
replForComposition ea = do
|
||||||
|
evalComposition <- getEvalCompositionFile
|
||||||
|
let args =
|
||||||
|
[ "repl", evalComposition ]
|
||||||
|
++ argArgs ea
|
||||||
|
++ map toS (evalUserArgs ea)
|
||||||
|
procSpec = (proc "nix" args) { cwd = evalWorkDir ea }
|
||||||
|
|
||||||
|
withCreateProcess procSpec $ \_in _out _err procHandle -> do
|
||||||
|
|
||||||
|
exitCode <- waitForProcess procHandle
|
||||||
|
|
||||||
|
case exitCode of
|
||||||
|
ExitSuccess -> pass
|
||||||
|
ExitFailure 1 -> exitFailure
|
||||||
|
e@ExitFailure {} -> do
|
||||||
|
throwIO $ FatalError $ "nix repl failed with " <> show exitCode
|
||||||
|
exitWith e
|
||||||
|
|
||||||
argArgs :: EvaluationArgs -> [[Char]]
|
argArgs :: EvaluationArgs -> [[Char]]
|
||||||
argArgs ea =
|
argArgs ea =
|
||||||
[ "--argstr"
|
[ "--argstr"
|
||||||
|
|
Loading…
Reference in a new issue