diff options
author | Tom Smeding <tom@tomsmeding.com> | 2021-02-17 16:01:53 +0100 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2021-02-17 16:01:53 +0100 |
commit | 1a7c345d3d530c566840c72f59a932f292cefd09 (patch) | |
tree | a9a5d4d96b6ae0fcd0f632f427b52ed0c9fe954a /Coolbal/Options.hs |
Initial
Diffstat (limited to 'Coolbal/Options.hs')
-rw-r--r-- | Coolbal/Options.hs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Coolbal/Options.hs b/Coolbal/Options.hs new file mode 100644 index 0000000..35b774c --- /dev/null +++ b/Coolbal/Options.hs @@ -0,0 +1,42 @@ +module Coolbal.Options ( + Options(..), + BuildOptions(..), + optionParser, +) where + +import Options.Applicative + + +data Options + = Build BuildOptions + | Clean + | Configure + deriving (Show) + +data BuildOptions = BuildOptions (Maybe String) + deriving (Show) + +optionParser :: ParserInfo Options +optionParser = + info (root <**> helper) + (fullDesc + <> header "coolbal - Faster cabal for common cases" + <> progDesc "Some simple Haskell projects don't need all the complexity of \ + \Cabal's re-configuration logic. Coolbal can take an already-built \ + \Cabal project and rebuild it as long as you don't change the \ + \configuration too much, and as long as you don't use too-special \ + \Cabal features. Always check that coolbal gives you the expected \ + \result.") + +root :: Parser Options +root = + hsubparser ( + command "build" (info (Build <$> buildOptions) + (progDesc "Build the project")) + <> command "clean" (info (pure Clean) + (progDesc "Clean coolbal's files for this project")) + <> command "configure" (info (pure Configure) + (progDesc "Initialise coolbal for this project"))) + +buildOptions :: Parser BuildOptions +buildOptions = BuildOptions <$> optional (argument str (metavar "TARGET")) |