summaryrefslogtreecommitdiff
path: root/Omni
diff options
context:
space:
mode:
Diffstat (limited to 'Omni')
-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