zwirn-0.2.2.0: app/zwirnzi/Main.hs
module Main where
{-
Main.hs - entry point of the editor program
Copyright (C) 2023, Martin Gius
This library is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this library. If not, see <http://www.gnu.org/licenses/>.
-}
import CI.Backend
import CI.Config
import CI.Setup
import Conferer as Conf
import Control.Concurrent.MVar
import Control.Monad (void)
import qualified LSP.Main as LSP
import System.IO (BufferMode (..), hSetBuffering, stdin, stdout)
main :: IO ()
main = do
hSetBuffering stdin NoBuffering
config <- getConfig
fullConfig <- Conf.fetch config
env <- setup fullConfig
envMV <- newMVar env
if cliMode fullConfig
then do
hSetBuffering stdout NoBuffering
runZwirnCI env evalInputLoop
else do
hSetBuffering stdout LineBuffering
void $ LSP.main envMV
cliMode :: FullConfig -> Bool
cliMode = ciConfigCli . fullConfigCi