-- | Copyright: (c) 2021-2022 berberman
-- SPDX-License-Identifier: MIT
-- Maintainer: berberman <[email protected]>
-- Stability: experimental
-- Portability: portable
module NvFetcher.Config where

import Data.Default
import Development.Shake

-- | Nvfetcher configuration
data Config = Config
  { Config -> ShakeOptions
shakeConfig :: ShakeOptions,
    Config -> FilePath
buildDir :: FilePath,
    Config -> Rules ()
customRules :: Rules (),
    Config -> Action ()
actionAfterBuild :: Action (),
    Config -> Action ()
actionAfterClean :: Action (),
    Config -> Int
retry :: Int,
    Config -> Maybe FilePath
filterRegex :: Maybe String,
    Config -> Bool
cacheNvchecker :: Bool,
    Config -> Bool
keepOldFiles :: Bool,
    -- | Absolute path
    Config -> Maybe FilePath
keyfile :: Maybe FilePath,
    -- | When set to 'True', nvfetcher will keep going even if some packages failed to /fetch/
    Config -> Bool
keepGoing :: Bool
  }

instance Default Config where
  def :: Config
def =
    Config
      { shakeConfig :: ShakeOptions
shakeConfig =
          ShakeOptions
shakeOptions
            { shakeProgress = progressSimple,
              shakeThreads = 0
            },
        buildDir :: FilePath
buildDir = FilePath
"_sources",
        customRules :: Rules ()
customRules = () -> Rules ()
forall a. a -> Rules a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (),
        actionAfterBuild :: Action ()
actionAfterBuild = () -> Action ()
forall a. a -> Action a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (),
        actionAfterClean :: Action ()
actionAfterClean = () -> Action ()
forall a. a -> Action a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (),
        retry :: Int
retry = Int
3,
        filterRegex :: Maybe FilePath
filterRegex = Maybe FilePath
forall a. Maybe a
Nothing,
        cacheNvchecker :: Bool
cacheNvchecker = Bool
True,
        keepOldFiles :: Bool
keepOldFiles = Bool
False,
        keyfile :: Maybe FilePath
keyfile = Maybe FilePath
forall a. Maybe a
Nothing,
        keepGoing :: Bool
keepGoing = Bool
False
      }