module Proteome.Data.Env where

import Ribosome (Buffer)

import Proteome.Data.Project(Project)
import Proteome.Data.ProjectMetadata (ProjectMetadata (DirProject, VirtualProject))
import Proteome.Data.ProjectType (ProjectType)
import Proteome.Data.Replace (Replace)

data Env =
  Env {
    Env -> Project
mainProject :: Project,
    Env -> [Project]
projects :: [Project],
    Env -> Int
currentProjectIndex :: Int,
    Env -> [Text]
configLog :: [Text],
    Env -> [Buffer]
buffers :: [Buffer],
    Env -> Maybe Replace
replace :: Maybe Replace
  }
  deriving stock (Int -> Env -> ShowS
[Env] -> ShowS
Env -> String
(Int -> Env -> ShowS)
-> (Env -> String) -> ([Env] -> ShowS) -> Show Env
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Env] -> ShowS
$cshowList :: [Env] -> ShowS
show :: Env -> String
$cshow :: Env -> String
showsPrec :: Int -> Env -> ShowS
$cshowsPrec :: Int -> Env -> ShowS
Show, (forall x. Env -> Rep Env x)
-> (forall x. Rep Env x -> Env) -> Generic Env
forall x. Rep Env x -> Env
forall x. Env -> Rep Env x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Env x -> Env
$cfrom :: forall x. Env -> Rep Env x
Generic)
  deriving anyclass (Env
Env -> Default Env
forall a. a -> Default a
def :: Env
$cdef :: Env
Default)

mainType :: Env -> Maybe ProjectType
mainType :: Env -> Maybe ProjectType
mainType Env
env =
  case Env
env Env
-> Getting ProjectMetadata Env ProjectMetadata -> ProjectMetadata
forall s a. s -> Getting a s a -> a
^. (IsLabel
  "mainProject"
  ((Project -> Const ProjectMetadata Project)
   -> Env -> Const ProjectMetadata Env)
(Project -> Const ProjectMetadata Project)
-> Env -> Const ProjectMetadata Env
#mainProject ((Project -> Const ProjectMetadata Project)
 -> Env -> Const ProjectMetadata Env)
-> ((ProjectMetadata -> Const ProjectMetadata ProjectMetadata)
    -> Project -> Const ProjectMetadata Project)
-> Getting ProjectMetadata Env ProjectMetadata
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IsLabel
  "meta"
  ((ProjectMetadata -> Const ProjectMetadata ProjectMetadata)
   -> Project -> Const ProjectMetadata Project)
(ProjectMetadata -> Const ProjectMetadata ProjectMetadata)
-> Project -> Const ProjectMetadata Project
#meta) of
    DirProject ProjectName
_ ProjectRoot
_ Maybe ProjectType
tpe ->
      Maybe ProjectType
tpe
    VirtualProject ProjectName
_ ->
      Maybe ProjectType
forall a. Maybe a
Nothing