aboutsummaryrefslogtreecommitdiff
path: root/hsm-core
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2025-09-07 13:43:15 +0000
committerPaul Oliver <contact@pauloliver.dev>2025-09-07 13:44:22 +0000
commitef0713cbd90d6b84da7ea67e6dfc1fe5ab5bff86 (patch)
treec4a6b48f498be3381a24a9c2183d3a50c0291a62 /hsm-core
parentb401cfd4780882a01b3656da2aa244592cb1d242 (diff)
Adds generic app launcher helper function
Diffstat (limited to 'hsm-core')
-rw-r--r--hsm-core/Hsm/Core/App.hs9
-rw-r--r--hsm-core/Hsm/Core/Options.hs8
-rw-r--r--hsm-core/hsm-core.cabal2
3 files changed, 10 insertions, 9 deletions
diff --git a/hsm-core/Hsm/Core/App.hs b/hsm-core/Hsm/Core/App.hs
new file mode 100644
index 0000000..12849d4
--- /dev/null
+++ b/hsm-core/Hsm/Core/App.hs
@@ -0,0 +1,9 @@
+module Hsm.Core.App
+ ( runApp
+ ) where
+
+import Effectful (Eff, IOE, runEff)
+import Options.Applicative (Parser, (<**>), execParser, fullDesc, helper, info, progDesc)
+
+runApp :: Parser o -> String -> (o -> Eff '[ IOE] a) -> IO a
+runApp parser desc app = execParser (info (parser <**> helper) $ fullDesc <> progDesc desc) >>= runEff . app
diff --git a/hsm-core/Hsm/Core/Options.hs b/hsm-core/Hsm/Core/Options.hs
deleted file mode 100644
index eeeee97..0000000
--- a/hsm-core/Hsm/Core/Options.hs
+++ /dev/null
@@ -1,8 +0,0 @@
-module Hsm.Core.Options
- ( getOptions
- ) where
-
-import Options.Applicative (Parser, (<**>), execParser, fullDesc, helper, info, progDesc)
-
-getOptions :: Parser a -> String -> IO a
-getOptions parser desc = execParser . info (parser <**> helper) $ fullDesc <> progDesc desc
diff --git a/hsm-core/hsm-core.cabal b/hsm-core/hsm-core.cabal
index e435f19..163e430 100644
--- a/hsm-core/hsm-core.cabal
+++ b/hsm-core/hsm-core.cabal
@@ -13,8 +13,8 @@ library
default-language: GHC2024
exposed-modules:
+ Hsm.Core.App
Hsm.Core.Bracket
Hsm.Core.Serial
- Hsm.Core.Options
ghc-options: -O2 -Wall -Werror -Wno-star-is-type -Wunused-packages