module Vimeta.Core.Process
( tagFile,
)
where
import System.Exit (ExitCode (..))
import System.Process
import Vimeta.Core.Config
import Vimeta.Core.Vimeta
tagFile :: Text -> Vimeta IO ()
tagFile cmd = do
dryRun <- configDryRun <$> asks ctxConfig
if dryRun then doDryRun else doRealRun
where
doDryRun :: Vimeta IO ()
doDryRun =
verbose "dry run: skipping tagging command"
>> verbose cmd
doRealRun :: Vimeta IO ()
doRealRun = do
verbose cmd
code <- liftIO (spawnCommand (toString cmd) >>= waitForProcess)
case code of
ExitSuccess ->
pass
ExitFailure n ->
throwError ("command failed (" ++ show n ++ "): " ++ toString cmd)