1{-# LANGUAGE LambdaCase #-}
2{-# LANGUAGE RecordWildCards #-}
3{-# LANGUAGE TemplateHaskell #-}
5module Stack.Config where
11import Stack.Config.Yaml as Yaml
13newtype StackResolver = StackResolver { fromStackResolver :: Text }
14 deriving (Eq, Ord, Show)
16makePrisms ''StackResolver
18unStackResolver :: StackResolver -> String
19unStackResolver = T.unpack . fromStackResolver
24 } deriving (Eq, Ord, Show)
30 | StackRepoGit RepoGit
31 deriving (Eq, Ord, Show)
33makePrisms ''StackLocation
35data StackPackage = StackPackage
36 { _spLocation :: StackLocation
38 } deriving (Eq, Ord, Show)
40makeLenses ''StackPackage
42newtype StackExtraDep = StackExtraDep { fromStackExtraDep :: Text }
43 deriving (Eq, Ord, Show)
45makePrisms ''StackExtraDep
47unExtraDep :: StackExtraDep -> String
48unExtraDep = T.unpack . fromStackExtraDep
50data StackConfig = StackConfig
51 { _scResolver :: StackResolver
52 , _scPackages :: [StackPackage]
53 , _scExtraDeps :: [StackExtraDep]
54 } deriving (Eq, Ord, Show)
56makeLenses ''StackConfig
58fromYamlConfig :: Yaml.Config -> StackConfig
59fromYamlConfig c = StackConfig{..}
61 _scResolver = coerce $ c ^. cResolver
62 _scPackages = fromYamlPackage <$> c ^. cPackages
63 _scExtraDeps = StackExtraDep <$> c ^. cExtraDeps
65fromYamlPackage :: Yaml.Package -> StackPackage
66fromYamlPackage = \case
68 StackPackage (StackPath path) False
69 Yaml.LocationSimple (Yaml.Location path extraDep) ->
70 StackPackage (StackPath path) (fromMaybe False extraDep)
71 Yaml.LocationGit (Location git extraDep) ->
72 StackPackage (StackRepoGit $ fromYamlGit git) (fromMaybe False extraDep)
74fromYamlGit :: Yaml.Git -> RepoGit
75fromYamlGit yg = RepoGit{..}
78 _rgCommit = yg ^. gCommit
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list