From 0a1843b763764a2a7eb434b829b0dda4b624cbb0 Mon Sep 17 00:00:00 2001 From: Jim McStanton Date: Wed, 26 Feb 2020 05:04:50 -0600 Subject: Expose CLI arg parser internals --- lib/Hakyll/Main.hs | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/Hakyll/Main.hs b/lib/Hakyll/Main.hs index 5abf3a7..ae2a5bc 100644 --- a/lib/Hakyll/Main.hs +++ b/lib/Hakyll/Main.hs @@ -3,7 +3,13 @@ {-# LANGUAGE CPP #-} module Hakyll.Main - ( hakyll + ( optionParser + , commandParser + , defaultParser + , defaultParserPure + , defaultParserPrefs + , defaultParserInfo + , hakyll , hakyllWith , hakyllWithArgs , hakyllWithExitCode @@ -72,12 +78,25 @@ hakyllWithExitCodeAndArgs conf args rules = do -------------------------------------------------------------------------------- defaultParser :: Config.Configuration -> IO Options defaultParser conf = - OA.customExecParser (OA.prefs OA.showHelpOnError) - (OA.info (OA.helper <*> optionParser conf) - (OA.fullDesc <> OA.progDesc - (progName ++ " - Static site compiler created with Hakyll"))) + OA.customExecParser defaultParserPrefs (defaultParserInfo conf) +-------------------------------------------------------------------------------- +defaultParserPure :: Config.Configuration -> [String] -> OA.ParserResult Options +defaultParserPure conf = + OA.execParserPure defaultParserPrefs (defaultParserInfo conf) + + +-------------------------------------------------------------------------------- +defaultParserPrefs :: OA.ParserPrefs +defaultParserPrefs = OA.prefs OA.showHelpOnError + +-------------------------------------------------------------------------------- +defaultParserInfo :: Config.Configuration -> OA.ParserInfo Options +defaultParserInfo conf = + OA.info (OA.helper <*> optionParser conf) (OA.fullDesc <> OA.progDesc ( + progName ++ " - Static site compiler created with Hakyll")) + -------------------------------------------------------------------------------- invokeCommands :: Command -> Config.Configuration -> Check.Check -> Logger.Logger -> Rules a -> IO ExitCode -- cgit v1.2.3