From 37079340575260db4cdb31d1f6d97ee23deff102 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Sat, 22 Nov 2025 14:45:06 -0500 Subject: fix: fix compilation errors in Omni/Agent.hs Amp-Thread-ID: https://ampcode.com/threads/T-ca3b086b-5a85-422a-b13d-256784c04221 Co-authored-by: Amp --- Omni/Agent.hs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'Omni/Agent.hs') diff --git a/Omni/Agent.hs b/Omni/Agent.hs index bad2737..be0b7e7 100644 --- a/Omni/Agent.hs +++ b/Omni/Agent.hs @@ -22,6 +22,7 @@ import qualified System.Directory as Directory import qualified System.Environment as Env import qualified System.Exit as Exit import System.FilePath (()) +import qualified System.IO as IO import qualified System.IO.Temp as Temp import qualified System.Process as Process @@ -78,6 +79,14 @@ move args | args `Cli.has` Cli.command "setup" = setup args | otherwise = putStrLn (Cli.usage help) +getArgOrExit :: Cli.Arguments -> Cli.Option -> IO String +getArgOrExit args opt = + case Cli.getArg args opt of + Just val -> pure val + Nothing -> do + putText <| "Error: Missing required argument " <> Text.pack (show opt) + Exit.exitFailure + harvest :: Cli.Arguments -> IO () harvest args = do let path = Cli.getArgWithDefault args "." (Cli.longOption "path") @@ -119,8 +128,8 @@ processBranch repo updated branch = do mergeDriver :: Cli.Arguments -> IO () mergeDriver args = do - ours <- Cli.getArgOrExit args (Cli.argument "ours") - theirs <- Cli.getArgOrExit args (Cli.argument "theirs") + ours <- getArgOrExit args (Cli.argument "ours") + theirs <- getArgOrExit args (Cli.argument "theirs") -- Set TASK_DB_PATH to ours (the file git provided as the current version) Env.setEnv "TASK_DB_PATH" ours @@ -129,7 +138,7 @@ mergeDriver args = do setup :: Cli.Arguments -> IO () setup args = do - nameStr <- Cli.getArgOrExit args (Cli.argument "name") + nameStr <- getArgOrExit args (Cli.argument "name") let name = Text.pack nameStr root <- Git.getRepoRoot "." let worktreePath = root <> "/../" <> nameStr -- cgit v1.2.3