Skip to content

Commit

Permalink
Implement the final getWorkDir
Browse files Browse the repository at this point in the history
  • Loading branch information
samtay committed Dec 13, 2016
1 parent 6635875 commit d66d260
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Dockmaster/Config/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import Data.Monoid ((<>), mconcat, First(..))
import Control.Monad (liftM)
default (T.Text)

---------- dm config functions ----------

-- | Get global dockmaster config
--
-- If config.yml fails to parse, returns Left error.
Expand Down Expand Up @@ -61,6 +63,8 @@ resolvePath = do
return $
getFirst . mconcat $ map First [envPathT >>= (return . fromText), homePath, etcPath]

---------- dm workdir functions ----------

-- | Resolve the appropriate dockmaster workdir.
--
-- For example, if @$CWD/dockmaster.yml@ exists, then
Expand All @@ -80,8 +84,15 @@ resolvePath = do
-- (3) @$CWD/deploybot/dockmaster.yml@ does /not/ exist, then
-- >>> getWorkDir "deploybot"
-- Right "$HOME/git/deploybot"
--
-- TODO Use monad transformers for all Sh (Either a b) types, like a real man
getWorkDir :: FilePath -> Sh (Either T.Text FilePath)
getWorkDir p = undefined
getWorkDir p = do
eCfg <- config
case eCfg of
(Left err) -> return $ Left err
(Right cfg) -> getWorkDir' cfg p


-- | Same thing as 'getWorkDir' but uses a 'Config' argument instead of
-- resolving one.
Expand Down

0 comments on commit d66d260

Please sign in to comment.