1module TutorialD.Interpreter.Import.TutorialD where
3import TutorialD.Interpreter.Import.Base
4import TutorialD.Interpreter.Base
5import TutorialD.Interpreter.DatabaseContextExpr
6import Text.Megaparsec.Text
7import Text.Megaparsec hiding (try)
9import qualified ProjectM36.Error as PM36E
10import qualified Data.Text as T
11import Control.Exception
12import qualified Data.ByteString as BS
13import qualified Data.Text.Encoding as TE
14--import a file containing TutorialD database context expressions
16importTutorialD :: FilePath -> IO (Either RelationalError DatabaseContextExpr)
17importTutorialD pathIn = do
18 eTutdBytes <- try (BS.readFile pathIn) :: IO (Either IOError BS.ByteString)
20 Left err -> return $ Left (ImportError $ T.pack (show err))
22 case TE.decodeUtf8' tutdBytes of
23 Left err -> pure (Left (ImportError $ T.pack (show err)))
25 case parse multipleDatabaseContextExprP "import" tutdUtf8 of
26 --parseErrorPretty is new in megaparsec 5
27 Left err -> pure (Left (PM36E.ParseError (T.pack (show err))))
28 Right expr -> pure (Right expr)
30tutdImportP :: Parser DatabaseContextDataImportOperator
32 reserved ":importtutd"
35 return $ DatabaseContextDataImportOperator (T.unpack path) importTutorialD
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list