From 89aab732dc3d484b99c0761728285bca6f6b1ba0 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Sun, 7 Sep 2025 19:23:37 +0000 Subject: Adds another formatting/cleaning round --- hsm-core/Hsm/Core/App.hs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'hsm-core/Hsm/Core/App.hs') diff --git a/hsm-core/Hsm/Core/App.hs b/hsm-core/Hsm/Core/App.hs index 12849d4..88dabb2 100644 --- a/hsm-core/Hsm/Core/App.hs +++ b/hsm-core/Hsm/Core/App.hs @@ -1,9 +1,20 @@ +-- Provides combinators for bootstrapping applications with: +-- - Automated command-line parsing +-- - Help text generation module Hsm.Core.App - ( runApp - ) where + ( bootstrapApp + , bootstrapAppNoEcho + ) +where -import Effectful (Eff, IOE, runEff) -import Options.Applicative (Parser, (<**>), execParser, fullDesc, helper, info, progDesc) +import Data.Composition ((.:.)) +import Options.Applicative (Parser, execParser, fullDesc, helper, info, progDesc, (<**>)) +import System.IO.Echo (withoutInputEcho) -runApp :: Parser o -> String -> (o -> Eff '[ IOE] a) -> IO a -runApp parser desc app = execParser (info (parser <**> helper) $ fullDesc <> progDesc desc) >>= runEff . app +-- Launches a console application with input echo enabled +bootstrapApp :: Parser o -> String -> (o -> IO a) -> IO a +bootstrapApp parser desc app = execParser (info (parser <**> helper) $ fullDesc <> progDesc desc) >>= app + +-- Launches an application with hidden input echo +bootstrapAppNoEcho :: Parser o -> String -> (o -> IO a) -> IO a +bootstrapAppNoEcho = withoutInputEcho .:. bootstrapApp -- cgit v1.2.1