Commit 9fa38482 authored by Valentin Reis's avatar Valentin Reis
Browse files

Adds verbose mode to argonix.

parent 7748a27d
Pipeline #5360 passed with stage
in 34 seconds
......@@ -83,7 +83,7 @@ main = join $ execParser (info (opts <**> helper) idm)
<> help "Type of operation to run."
)
data StackArgs = StackArgs
data Args = Args
{
argopkgs :: Text
, verbosity :: Verbosity
......@@ -95,10 +95,10 @@ data StackArgs = StackArgs
, run :: Maybe Text
, overrides :: [(String, String)]
} deriving (Show)
data Verbosity = Verbose | Normal deriving (Show)
data Verbosity = Verbose | Normal deriving (Show, Eq)
instance Default StackArgs where
def = StackArgs
instance Default Args where
def = Args
{ verbosity = Normal,
argopkgs = "<argopkgs>",
enableApps = False,
......@@ -114,7 +114,7 @@ targetParser :: Parser String
targetParser =
strArgument (metavar "TARGET" <> showDefault <> help "The build target.")
executorParser :: Parser StackArgs
executorParser :: Parser Args
executorParser = do
argopkgs <- strOption
( long "argopkgs"
......@@ -156,7 +156,7 @@ executorParser = do
(long "run" <> metavar "COMMAND" <> help
"Command to run the environment instead of an interactive shell"
)
pure StackArgs {..}
pure Args {..}
where
targets :: Parser [Maybe (String, String)]
targets = traverse
......@@ -210,7 +210,7 @@ sudoRemoveFile printer desc filePath = do
cleanSocket :: FilePath -> Shell ()
cleanSocket = sudoRemoveFile printWarning "socket"
setupSystem :: StackArgs -> Shell ()
setupSystem :: Args -> Shell ()
setupSystem sa = do
printInfo "Setting the nix-build environment up."
printInfo "Cleaning sockets."
......@@ -249,17 +249,18 @@ setupSystem sa = do
empty
void $ printInfo "Done setting the environment for nix-build up."
nixArguments :: String -> StackArgs -> [String]
nixArguments target StackArgs {..} = [unpack argopkgs, "-A", target] ++ concat
[ ["--arg", longform <> "-src", p] | (longform, p) <- overrides ]
nixArguments :: String -> Args -> [String]
nixArguments target Args {..} = [unpack argopkgs, "-A", target]
++ concat [ ["--arg", longform <> "-src", p] | (longform, p) <- overrides ]
data NixCommand = NixBuild | NixShell
toCommand :: IsString p => NixCommand -> p
toCommand NixBuild = "nix-build"
toCommand NixShell = "nix-shell"
wrap :: NixCommand -> String -> StackArgs -> IO ()
wrap nixCommand target sa@StackArgs {..} = sh $ do
wrap :: NixCommand -> String -> Args -> IO ()
wrap nixCommand target sa@Args {..} = sh $ do
when (verbosity == Verbose) $ liftIO $ print sa
_ <- setupSystem sa
printCommand $ pack nixc <> " " <> pack (unwords arglist)
liftIO (executeFile nixc True arglist Nothing)
......@@ -287,7 +288,7 @@ wrap nixCommand target sa@StackArgs {..} = sh $ do
{-nixshell :: IO ()-}
{-nixshell = undefined-}
{-StackArgs {..} <- liftIO $ execParser opts-}
{-Args {..} <- liftIO $ execParser opts-}
{--- building nixArguments (pure stuff) and shellArguments (impure stuff)-}
{-let nixArguments = ["-A", if enableApps then "expe" else "test"] ++ concat-}
......
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