<commit_before>{-# LANGUAGE CPP             #-}
{-# LANGUAGE TemplateHaskell #-}

import           Control.Lens           hiding (value)
import           Control.Monad          (unless)
import           Data.Monoid
import           Data.Version           (showVersion)
import           Options.Applicative
import           System.Exit            (ExitCode (ExitSuccess), exitWith)
import           System.Process         (rawSystem)

import           Yesod.Core             (yesodVersion)

import           AddHandler             (addHandler)
import           Devel                  (DevelOpts (..), devel)
import           Keter                  (keter)
import           Options                (injectDefaults)
import qualified Paths_yesod
import           Scaffolding.Scaffolder

#ifndef WINDOWS
import           Build                  (touch)

touch' :: IO ()
touch' = touch

windowsWarning :: String
windowsWarning = ""
#else
touch' :: IO ()
touch'  = return ()

windowsWarning :: String
windowsWarning = " (does not work on Windows)"
#endif

data CabalPgm = Cabal | CabalDev deriving (Show, Eq)

data Options = Options
               { _optCabalPgm :: CabalPgm
               , _optVerbose  :: Bool
               , _optCommand  :: Command
               }
  deriving (Show, Eq)

data Command = Init
             | Configure
             | Build { _buildExtraArgs :: [String] }
             | Touch
             | Devel { _develDisableApi  :: Bool
                     , _develSuccessHook :: Maybe String
                     , _develFailHook    :: Maybe String
                     , _develRescan      :: Int
                     , _develBuildDir    :: Maybe String
                     , _develIgnore      :: [String]
                     , _develExtraArgs   :: [String]
                     }
             | Test
             | AddHandler
             | Keter { _keterNoRebuild :: Bool }
             | Version
  deriving (Show, Eq)

makeLenses ''Options
makeLenses ''Command

cabalCommand :: Options -> String
cabalCommand mopt
  | mopt^.optCabalPgm == CabalDev = "cabal-dev"
  | otherwise                     = "cabal"


main :: IO ()
main = do
  o <- execParser =<< injectDefaults "yesod" [ ("yesod.devel.extracabalarg" , optCommand . develExtraArgs)
                                             , ("yesod.devel.ignore"        , optCommand . develIgnore)
                                             ] optParser'<commit_msg>handle default extra arguments for build command<commit_after>{-# LANGUAGE CPP             #-}
{-# LANGUAGE TemplateHaskell #-}

import           Control.Lens           hiding (value)
import           Control.Monad          (unless)
import           Data.Monoid
import           Data.Version           (showVersion)
import           Options.Applicative
import           System.Exit            (ExitCode (ExitSuccess), exitWith)
import           System.Process         (rawSystem)

import           Yesod.Core             (yesodVersion)

import           AddHandler             (addHandler)
import           Devel                  (DevelOpts (..), devel)
import           Keter                  (keter)
import           Options                (injectDefaults)
import qualified Paths_yesod
import           Scaffolding.Scaffolder

#ifndef WINDOWS
import           Build                  (touch)

touch' :: IO ()
touch' = touch

windowsWarning :: String
windowsWarning = ""
#else
touch' :: IO ()
touch'  = return ()

windowsWarning :: String
windowsWarning = " (does not work on Windows)"
#endif

data CabalPgm = Cabal | CabalDev deriving (Show, Eq)

data Options = Options
               { _optCabalPgm :: CabalPgm
               , _optVerbose  :: Bool
               , _optCommand  :: Command
               }
  deriving (Show, Eq)

data Command = Init
             | Configure
             | Build { _buildExtraArgs :: [String] }
             | Touch
             | Devel { _develDisableApi  :: Bool
                     , _develSuccessHook :: Maybe String
                     , _develFailHook    :: Maybe String
                     , _develRescan      :: Int
                     , _develBuildDir    :: Maybe String
                     , _develIgnore      :: [String]
                     , _develExtraArgs   :: [String]
                     }
             | Test
             | AddHandler
             | Keter { _keterNoRebuild :: Bool }
             | Version
  deriving (Show, Eq)

makeLenses ''Options
makeLenses ''Command

cabalCommand :: Options -> String
cabalCommand mopt
  | mopt^.optCabalPgm == CabalDev = "cabal-dev"
  | otherwise                     = "cabal"


main :: IO ()
main = do
  o <- execParser =<< injectDefaults "yesod" [ ("yesod.devel.extracabalarg" , optCommand . develExtraArgs)
                                             , ("yesod.devel.ignore"        , optCommand . develIgnore)
                                             , ("yesod.build.extracabalarg" , optCommand . buildExtraArgs)
                                             ] optParser'
{'fraction_non_alphanumeric': 0.08359936153232242, 'fraction_numerical': 0.0, 'mean_word_length': 1.383737517831669, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7169155', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1270, 'n_words': 322}