summaryrefslogtreecommitdiff
path: root/Omni/Agent.hs
diff options
context:
space:
mode:
authorBen Sima <ben@bensima.com>2025-11-22 14:45:06 -0500
committerBen Sima <ben@bensima.com>2025-11-22 14:45:06 -0500
commit37079340575260db4cdb31d1f6d97ee23deff102 (patch)
tree08dd3e20108e3e4ba73370f375f4e73b7e4afc27 /Omni/Agent.hs
parent42027b3dd8c3caa66eb7c0279b0bf70123380d41 (diff)
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 <amp@ampcode.com>
Diffstat (limited to 'Omni/Agent.hs')
-rw-r--r--Omni/Agent.hs15
1 files changed, 12 insertions, 3 deletions
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