summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJim McStanton <jim.h.stanton@gmail.com>2020-02-26 05:04:50 -0600
committerGitHub <noreply@github.com>2020-02-26 12:04:50 +0100
commit0a1843b763764a2a7eb434b829b0dda4b624cbb0 (patch)
tree667dc535d011bcc280387e2217e07264352cd97d /lib
parentd2ee5b2b0eb2afb970ab8d4feed84434dc8236e0 (diff)
downloadhakyll-0a1843b763764a2a7eb434b829b0dda4b624cbb0.tar.gz
Expose CLI arg parser internals
Diffstat (limited to 'lib')
-rw-r--r--lib/Hakyll/Main.hs29
1 files changed, 24 insertions, 5 deletions
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,13 +78,26 @@ 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
invokeCommands args conf check logger rules =