Separate hsfiles command

This commit is contained in:
Michael Snoyman 2014-03-06 07:35:05 +02:00
parent a4ab0530ca
commit d2745fc277

View File

@ -47,7 +47,8 @@ data Options = Options
} }
deriving (Show, Eq) deriving (Show, Eq)
data Command = Init { _initBare, _initHsFiles :: Bool } data Command = Init { _initBare :: Bool }
| HsFiles
| Configure | Configure
| Build { buildExtraArgs :: [String] } | Build { buildExtraArgs :: [String] }
| Touch | Touch
@ -96,7 +97,8 @@ main = do
] optParser' ] optParser'
let cabal = rawSystem' (cabalCommand o) let cabal = rawSystem' (cabalCommand o)
case optCommand o of case optCommand o of
Init bare hsfiles -> if hsfiles then mkHsFile else scaffold bare Init bare -> scaffold bare
HsFiles -> mkHsFile
Configure -> cabal ["configure"] Configure -> cabal ["configure"]
Build es -> touch' >> cabal ("build":es) Build es -> touch' >> cabal ("build":es)
Touch -> touch' Touch -> touch'
@ -125,9 +127,10 @@ optParser = Options
<$> flag Cabal CabalDev ( long "dev" <> short 'd' <> help "use cabal-dev" ) <$> flag Cabal CabalDev ( long "dev" <> short 'd' <> help "use cabal-dev" )
<*> switch ( long "verbose" <> short 'v' <> help "More verbose output" ) <*> switch ( long "verbose" <> short 'v' <> help "More verbose output" )
<*> subparser ( command "init" <*> subparser ( command "init"
(info (Init <$> (switch (long "bare" <> help "Create files in current folder")) (info (Init <$> (switch (long "bare" <> help "Create files in current folder")))
<*> (switch (long "hsfiles" <> help "Create a hsfiles file for the current folder")))
(progDesc "Scaffold a new site")) (progDesc "Scaffold a new site"))
<> command "hsfiles" (info (pure HsFiles)
(progDesc "Create a hsfiles file for the current folder"))
<> command "configure" (info (pure Configure) <> command "configure" (info (pure Configure)
(progDesc "Configure a project for building")) (progDesc "Configure a project for building"))
<> command "build" (info (Build <$> extraCabalArgs) <> command "build" (info (Build <$> extraCabalArgs)