@@ -38,7 +38,7 @@ import Nix.Utils
3838import Nix.Var
3939import Nix.Value.Monad
4040import Options.Applicative hiding ( ParserResult (.. ) )
41- import Prettyprinter hiding (list )
41+ import Prettyprinter hiding ( list )
4242import Prettyprinter.Render.Text
4343import qualified Repl
4444import System.FilePath
@@ -49,24 +49,29 @@ main :: IO ()
4949main = do
5050 time <- getCurrentTime
5151 opts <- execParser (nixOptionsInfo time)
52- runWithBasicEffectsIO opts $
52+
53+ runWithBasicEffectsIO opts $ execContentsFilesOrRepl opts
54+
55+ where
56+ execContentsFilesOrRepl opts =
5357 maybe
5458 (maybe
5559 (maybe
5660 (list
57- (withNixContext mempty Repl. main)
61+ (withNixContext mempty Repl. main) -- run REPL
5862 (\ case
59- [" -" ] ->
60- handleResult opts mempty
61- . parseNixTextLoc
62- =<< liftIO Text. getContents
63+ [" -" ] -> handleResult opts mempty . parseNixTextLoc =<< liftIO Text. getContents
6364 _paths -> traverse_ (processFile opts) _paths
6465 )
6566 (filePaths opts)
6667 )
67- (\ case
68- " -" -> traverse_ (processFile opts) . lines =<< liftIO getContents
69- _path -> traverse_ (processFile opts) . lines =<< liftIO (readFile _path)
68+ (\ x ->
69+ -- use Text as in the base case, requires changing FilePath -> Text
70+ traverse_ (processFile opts) . lines =<< liftIO
71+ (case x of
72+ " -" -> getContents -- get user input
73+ _path -> readFile _path
74+ )
7075 )
7176 (fromFile opts)
7277 )
@@ -79,7 +84,7 @@ main = do
7984 process opts (pure file) =<< liftIO (readCache path)
8085 )
8186 (readFrom opts)
82- where
87+
8388 processFile opts path = do
8489 eres <- parseNixFileLoc path
8590 handleResult opts (pure path) eres
0 commit comments