<commit_before>module Main where

import System.Console.Haskeline
import System.IO
import System.Environment
import System.Exit
import System.FilePath ((</>), addTrailingPathSeparator)
import System.Directory

import Data.Maybe
import Data.Version
import Control.Monad.Trans.State.Strict ( execStateT, get, put )
import Control.Monad ( when )

import Idris.Core.TT
import Idris.Core.Typecheck
import Idris.Core.Evaluate
import Idris.Core.Constraints

import Idris.AbsSyntax
import Idris.Parser
import Idris.REPL
import Idris.ElabDecls
import Idris.Primitives
import Idris.Imports
import Idris.Error
import Idris.CmdOptions

import IRTS.System ( getLibFlags, getIdrisLibDir, getIncFlags )

import Util.DynamicLinker
import Util.System

import Pkg.Package

import Paths_idris

-- Main program reads command line options, parses the main program, and gets
-- on with the REPL.

main :: IO ()
main = do
          when isWindows $ do hSetEncoding stdout utf8
          opts <- runArgParser
          runMain (runIdris opts)

runIdris :: [Opt] -> Idris ()
runIdris opts = do
       when (ShowIncs `elem` opts) $ runIO showIncs
       when (ShowLibs `elem` opts) $ runIO showLibs
       when (ShowLibdir `elem` opts) $ runIO showLibdir
       when (ShowPkgs `elem` opts) $ runIO showPkgs
       case opt getClient opts of
           []    -> return ()
           (c:_) -> do setVerbose False
                       setQuiet True
                       runIO $ runClient (getPort opts) c
                       runIO $ exitWith ExitSuccess
       case opt getPkgCheck opts of
           [] -> return ()
           fs -> do runIO $ mapM_ (checkPkg (WarnOnly `elem` opts) True) fs
                    runIO $ exitWith ExitSuccess
       case opt getPkgClean opts of
           [] -> return ()
           fs -> do runIO $ mapM_ cleanPkg fs
                    runIO $ exitWith ExitSuccess
       case opt getPkgMkDoc opts of                -- IdrisDoc
           [] -> return ()
           fs -> do runIO $ mapM_ documentPkg fs
                    runIO $ exitWith ExitSuccess
       case opt getPkgTest opts of
           [] -> return ()
           fs -> do runIO $ mapM_ testPkg fs
                    runIO $ exitWith ExitSuccess
       case opt getPkg opts of
           [] -> case opt getPkgREPL opts of
                      [] -> idrisMain opts
                      [f] -> replPkg f
                      _ -> ifail "Too many packages"
           fs -> runIO $ mapM_ (buildPkg (WarnOnly `elem` opts)) fs

showver :: IO b
showver = do putStrLn $ "Idris version " ++ ver
             exitWith ExitSuccess

showLibs :: IO b
showLibs = do libFlags <- getLibFlags
              putStrLn $ unwords libFlags
              exitWith ExitSuccess

showLibdir :: IO b
showLibdir = do dir <- getIdrisLibDir
                putStrLn dir
                exitWith ExitSuccess

showIncs :: IO b
showIncs = do incFlags <- getIncFlags
              putStrLn $ unwords incFlags
              exitWith ExitSuccess

-- | List idris packages installed
showPkgs :: IO b
showPkgs = do mapM putStrLn =<< installedPackages
              exitWith ExitSuccess
<commit_msg>disable windows specific UTF8 encoding<commit_after>module Main where

import System.Console.Haskeline
import System.IO
import System.Environment
import System.Exit
import System.FilePath ((</>), addTrailingPathSeparator)
import System.Directory

import Data.Maybe
import Data.Version
import Control.Monad.Trans.State.Strict ( execStateT, get, put )
import Control.Monad ( when )

import Idris.Core.TT
import Idris.Core.Typecheck
import Idris.Core.Evaluate
import Idris.Core.Constraints

import Idris.AbsSyntax
import Idris.Parser
import Idris.REPL
import Idris.ElabDecls
import Idris.Primitives
import Idris.Imports
import Idris.Error
import Idris.CmdOptions

import IRTS.System ( getLibFlags, getIdrisLibDir, getIncFlags )

import Util.DynamicLinker

import Pkg.Package

import Paths_idris

-- Main program reads command line options, parses the main program, and gets
-- on with the REPL.

main :: IO ()
main = do opts <- runArgParser
          runMain (runIdris opts)

runIdris :: [Opt] -> Idris ()
runIdris opts = do
       when (ShowIncs `elem` opts) $ runIO showIncs
       when (ShowLibs `elem` opts) $ runIO showLibs
       when (ShowLibdir `elem` opts) $ runIO showLibdir
       when (ShowPkgs `elem` opts) $ runIO showPkgs
       case opt getClient opts of
           []    -> return ()
           (c:_) -> do setVerbose False
                       setQuiet True
                       runIO $ runClient (getPort opts) c
                       runIO $ exitWith ExitSuccess
       case opt getPkgCheck opts of
           [] -> return ()
           fs -> do runIO $ mapM_ (checkPkg (WarnOnly `elem` opts) True) fs
                    runIO $ exitWith ExitSuccess
       case opt getPkgClean opts of
           [] -> return ()
           fs -> do runIO $ mapM_ cleanPkg fs
                    runIO $ exitWith ExitSuccess
       case opt getPkgMkDoc opts of                -- IdrisDoc
           [] -> return ()
           fs -> do runIO $ mapM_ documentPkg fs
                    runIO $ exitWith ExitSuccess
       case opt getPkgTest opts of
           [] -> return ()
           fs -> do runIO $ mapM_ testPkg fs
                    runIO $ exitWith ExitSuccess
       case opt getPkg opts of
           [] -> case opt getPkgREPL opts of
                      [] -> idrisMain opts
                      [f] -> replPkg f
                      _ -> ifail "Too many packages"
           fs -> runIO $ mapM_ (buildPkg (WarnOnly `elem` opts)) fs

showver :: IO b
showver = do putStrLn $ "Idris version " ++ ver
             exitWith ExitSuccess

showLibs :: IO b
showLibs = do libFlags <- getLibFlags
              putStrLn $ unwords libFlags
              exitWith ExitSuccess

showLibdir :: IO b
showLibdir = do dir <- getIdrisLibDir
                putStrLn dir
                exitWith ExitSuccess

showIncs :: IO b
showIncs = do incFlags <- getIncFlags
              putStrLn $ unwords incFlags
              exitWith ExitSuccess

-- | List idris packages installed
showPkgs :: IO b
showPkgs = do mapM putStrLn =<< installedPackages
              exitWith ExitSuccess

{'fraction_non_alphanumeric': 0.07137116219257354, 'fraction_numerical': 0.00032149172158816913, 'mean_word_length': 2.024793388429752, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1913924', 'n_tokens_mistral': 1854, 'n_tokens_neox': 1772, 'n_words': 592}