main :: IO ()
main = do
  o <- execParser =<< injectDefaults "yesod"
         [ ("yesod.devel.extracabalarg" , \o args -> o { optCommand =
                case optCommand o of
                    d@Devel{} -> d { develExtraArgs = args }
                    c -> c
                })
         , ("yesod.devel.ignore"        , \o args -> o { optCommand =
                case optCommand o of
                    d@Devel{} -> d { develIgnore = args }
                    c -> c
                })
         , ("yesod.build.extracabalarg" , \o args -> o { optCommand =
                case optCommand o of
                    b@Build{} -> b { buildExtraArgs = args }
                    c -> c
                })
         ] optParser'
  let cabal = rawSystem' (cabalCommand o)
  case optCommand o of
    Init{..}        -> scaffold _initBare _initName _initDatabase
    HsFiles         -> mkHsFile
    Configure       -> cabal ["configure"]
    Build es        -> touch' >> cabal ("build":es)
    Touch           -> touch'
    Keter{..}       -> keter (cabalCommand o) _keterNoRebuild _keterNoCopyTo
    Version         -> putStrLn ("yesod-bin version: " ++ showVersion Paths_yesod_bin.version)
    AddHandler{..}  -> addHandler addHandlerRoute addHandlerPattern addHandlerMethods
    Test            -> cabalTest cabal
    Devel{..}       -> let develOpts = DevelOpts
                             { isCabalDev   = optCabalPgm o == CabalDev
                             , forceCabal   = _develDisableApi
                             , verbose      = optVerbose o
                             , eventTimeout = _develRescan
                             , successHook  = _develSuccessHook
                             , failHook     = _develFailHook
                             , buildDir     = _develBuildDir
                             , develPort    = _develPort
                             , develTlsPort = _develTlsPort
                             , proxyTimeout = _proxyTimeout
                             , useReverseProxy = not _noReverseProxy
                             , terminateWith = if _interruptOnly then TerminateOnlyInterrupt else TerminateOnEnter
                             }
                       in devel develOpts develExtraArgs
  where
    cabalTest cabal = do touch'
                         _ <- cabal ["configure", "--enable-tests", "-flibrary-only"]
                         _ <- cabal ["build"]
                         cabal ["test"]
main :: IO ()
main = do
  o <- execParser =<< injectDefaults "yesod"
         [ ("yesod.devel.extracabalarg" , \o args -> o { optCommand =
                case optCommand o of
                    d@Devel{} -> d { develExtraArgs = args }
                    c -> c
                })
         , ("yesod.devel.ignore"        , \o args -> o { optCommand =
                case optCommand o of
                    d@Devel{} -> d { develIgnore = args }
                    c -> c
                })
         , ("yesod.build.extracabalarg" , \o args -> o { optCommand =
                case optCommand o of
                    b@Build{} -> b { buildExtraArgs = args }
                    c -> c
                })
         ] optParser'
  let cabal = rawSystem' (cabalCommand o)
  case optCommand o of
    Init{..}        -> scaffold _initBare _initName _initDatabase
    HsFiles         -> mkHsFile
    Configure       -> cabal ["configure"]
    Build es        -> touch' >> cabal ("build":es)
    Touch           -> touch'
    Keter{..}       -> keter (cabalCommand o) _keterNoRebuild _keterNoCopyTo
    Version         -> putStrLn ("yesod-bin version: " ++ showVersion Paths_yesod_bin.version)
    AddHandler{..}  -> addHandler addHandlerRoute addHandlerPattern addHandlerMethods
    Test            -> cabalTest cabal
    Devel{..}       -> let develOpts = DevelOpts
                             { isCabalDev   = optCabalPgm o == CabalDev
                             , forceCabal   = _develDisableApi
                             , verbose      = optVerbose o
                             , eventTimeout = _develRescan
                             , successHook  = _develSuccessHook
                             , failHook     = _develFailHook
                             , buildDir     = _develBuildDir
                             , develPort    = _develPort
                             , develTlsPort = _develTlsPort
                             , proxyTimeout = _proxyTimeout
                             , useReverseProxy = not _noReverseProxy
                             , terminateWith = if _interruptOnly then TerminateOnlyInterrupt else TerminateOnEnter
                             }
                       in devel develOpts develExtraArgs
  where
    cabalTest cabal = do touch'
                         _ <- cabal ["configure", "--enable-tests", "-flibrary-only"]
                         _ <- cabal ["build"]
                         cabal ["test"]
main = do
  o <- execParser =<< injectDefaults "yesod"
         [ ("yesod.devel.extracabalarg" , \o args -> o { optCommand =
                case optCommand o of
                    d@Devel{} -> d { develExtraArgs = args }
                    c -> c
                })
         , ("yesod.devel.ignore"        , \o args -> o { optCommand =
                case optCommand o of
                    d@Devel{} -> d { develIgnore = args }
                    c -> c
                })
         , ("yesod.build.extracabalarg" , \o args -> o { optCommand =
                case optCommand o of
                    b@Build{} -> b { buildExtraArgs = args }
                    c -> c
                })
         ] optParser'
  let cabal = rawSystem' (cabalCommand o)
  case optCommand o of
    Init{..}        -> scaffold _initBare _initName _initDatabase
    HsFiles         -> mkHsFile
    Configure       -> cabal ["configure"]
    Build es        -> touch' >> cabal ("build":es)
    Touch           -> touch'
    Keter{..}       -> keter (cabalCommand o) _keterNoRebuild _keterNoCopyTo
    Version         -> putStrLn ("yesod-bin version: " ++ showVersion Paths_yesod_bin.version)
    AddHandler{..}  -> addHandler addHandlerRoute addHandlerPattern addHandlerMethods
    Test            -> cabalTest cabal
    Devel{..}       -> let develOpts = DevelOpts
                             { isCabalDev   = optCabalPgm o == CabalDev
                             , forceCabal   = _develDisableApi
                             , verbose      = optVerbose o
                             , eventTimeout = _develRescan
                             , successHook  = _develSuccessHook
                             , failHook     = _develFailHook
                             , buildDir     = _develBuildDir
                             , develPort    = _develPort
                             , develTlsPort = _develTlsPort
                             , proxyTimeout = _proxyTimeout
                             , useReverseProxy = not _noReverseProxy
                             , terminateWith = if _interruptOnly then TerminateOnlyInterrupt else TerminateOnEnter
                             }
                       in devel develOpts develExtraArgs
  where
    cabalTest cabal = do touch'
                         _ <- cabal ["configure", "--enable-tests", "-flibrary-only"]
                         _ <- cabal ["build"]
                         cabal ["test"]