-- Provides combinators for bootstrapping applications with: -- - Automated command-line parsing -- - Help text generation module Hsm.Core.App ( bootstrapApp , bootstrapAppNoEcho ) where import Data.Composition ((.:.)) import Options.Applicative (Parser, execParser, fullDesc, helper, info, progDesc, (<**>)) import System.IO.Echo (withoutInputEcho) -- 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