-- | Default values for the data types in "Cartel.Ast".  These
-- defaults are genrally filled in with blank values.  Use these
-- default values where you can; by doing so you help future-proof
-- your code.  Use the default as a starting point and fill in the
-- values that you need.
module Cartel.Defaults where

import qualified Cartel.Ast as A

-- | A default 'A.Properties'.  'A.prCabalVersion' is @(1, 14)@ to
-- specify Cabal version 1.14; 'A.prBuildType' is 'A.Simple', and
-- 'A.prLicense' is 'A.BSD3'.  All other items are either the empty
-- 'String' or the empty list, including the 'A.prVersion', which is
-- left empty.
properties :: A.Properties
properties = A.Properties
  { A.prName = ""
  , A.prVersion = A.Version []
  , A.prCabalVersion = (1, 14)
  , A.prBuildType = A.Simple
  , A.prLicense = A.BSD3
  , A.prLicenseFile = ""
  , A.prLicenseFiles = []
  , A.prCopyright = ""
  , A.prAuthor = ""
  , A.prMaintainer = ""
  , A.prStability = ""
  , A.prHomepage = ""
  , A.prBugReports = ""
  , A.prPackageUrl = ""
  , A.prSynopsis = ""
  , A.prDescription = []
  , A.prCategory = ""
  , A.prTestedWith = []
  , A.prDataFiles = []
  , A.prDataDir = ""
  , A.prExtraSourceFiles = []
  , A.prExtraDocFiles = []
  , A.prExtraTmpFiles = []
  }

-- | A default 'A.Cabal'.  'properties' is used for 'A.cProperties',
-- and 'A.cLibrary' is 'Nothing'; all other lists are empty.
cabal :: A.Cabal
cabal = A.Cabal
  { A.cProperties = properties
  , A.cRepositories = []
  , A.cFlags = []
  , A.cLibrary = Nothing
  , A.cExecutables = []
  , A.cTestSuites = []
  , A.cBenchmarks = []
  }

-- | A default 'A.Repository'.  You must supply the VCS type,
-- information about the kind of repository ('A.Head' or 'A.This'),
-- and the repository location.  'A.repoBranch' and 'A.repoSubdir'
-- are empty.
repository
  :: A.Vcs
  -- ^ Type of VCS in use
  -> Maybe String
  -- ^ To use the @this@ repo kind, use Just String, where the
  -- String is the tag corresponding to the current branch.  To use
  -- the @head@ repository kind, use Nothing.
  -> String
  -- ^ Repo location
  -> A.Repository
repository v ms l = A.Repository
  { A.repoVcs = v
  , A.repoKind = maybe A.Head (const A.This) ms
  , A.repoLocation = l
  , A.repoBranch = ""
  , A.repoTag = maybe "" id ms
  , A.repoSubdir = ""
  }

-- | A default 'A.Flag'.  'A.flName' and 'A.flDescription' are
-- empty; 'A.flDefault' is 'True', and 'A.flManual' is 'False'.
flag :: A.Flag
flag = A.Flag
  { A.flName = ""
  , A.flDescription = ""
  , A.flDefault = True
  , A.flManual = False
  }