doCd :: FilePath -> FilePath -> String -> IO ()
doCd dbFile yxExe pattern = SQLite.withConnection dbFile $ \c -> do
    let conn = DbConnection c
    findProjects conn (modifyPattern pattern) >>= \case
        [] -> do
            isADirectory <- doesDirectoryExist pattern
            if isADirectory
                then newProject conn pattern >>= runProjEnv Nothing
                else error "No such project found, try \"yx ls PATTERN\"."
        [p] -> runProjEnv Nothing p
        ps -> printProjects ps
  where
    runProjEnv = runProjectEnvironment yxExe
doCd :: FilePath -> FilePath -> String -> IO ()
doCd dbFile yxExe pattern = SQLite.withConnection dbFile $ \c -> do
    let conn = DbConnection c
    findProjects conn (modifyPattern pattern) >>= \case
        [] -> do
            isADirectory <- doesDirectoryExist pattern
            if isADirectory
                then newProject conn pattern >>= runProjEnv Nothing
                else error "No such project found, try \"yx ls PATTERN\"."
        [p] -> runProjEnv Nothing p
        ps -> printProjects ps
  where
    runProjEnv = runProjectEnvironment yxExe
doCd dbFile yxExe pattern = SQLite.withConnection dbFile $ \c -> do
    let conn = DbConnection c
    findProjects conn (modifyPattern pattern) >>= \case
        [] -> do
            isADirectory <- doesDirectoryExist pattern
            if isADirectory
                then newProject conn pattern >>= runProjEnv Nothing
                else error "No such project found, try \"yx ls PATTERN\"."
        [p] -> runProjEnv Nothing p
        ps -> printProjects ps
  where
    runProjEnv = runProjectEnvironment yxExe