2import TutorialD.Interpreter
4import ProjectM36.Client
6import Options.Applicative
10parseArgs :: Parser InterpreterConfig
11parseArgs = LocalInterpreterConfig <$> parsePersistenceStrategy <*> parseHeadName <*> parseGhcPkgPaths <|>
12 RemoteInterpreterConfig <$> parseNodeId <*> parseDatabaseName <*> parseHeadName
14parsePersistenceStrategy :: Parser PersistenceStrategy
15parsePersistenceStrategy = CrashSafePersistence <$> (dbdirOpt <* fsyncOpt) <|>
16 MinimalPersistence <$> dbdirOpt <|>
19 dbdirOpt = strOption (short 'd' <>
20 long "database-directory" <>
21 metavar "DIRECTORY" <>
24 fsyncOpt = switch (short 'f' <>
26 help "Fsync all new transactions.")
28parseHeadName :: Parser HeadName
29parseHeadName = option auto (long "head" <>
30 help "Start session at head name." <>
34parseDatabaseName :: Parser DatabaseName
35parseDatabaseName = strOption (long "database" <>
37 help "Remote database name")
39parseNodeId :: Parser NodeId
40parseNodeId = createNodeId <$>
41 strOption (long "host" <>
43 help "Remote host name" <>
44 value "127.0.0.1") <*>
45 option auto (long "port" <>
48 value defaultServerPort)
50parseGhcPkgPaths :: Parser [GhcPkgPath]
51parseGhcPkgPaths = many (strOption (long "ghc-pkg-dir" <>
52 metavar "GHC_PACKAGE_DIRECTORY"))
54opts :: ParserInfo InterpreterConfig
55opts = info parseArgs idm
57connectionInfoForConfig :: InterpreterConfig -> ConnectionInfo
58connectionInfoForConfig (LocalInterpreterConfig pStrategy _ ghcPkgPaths) = InProcessConnectionInfo pStrategy outputNotificationCallback ghcPkgPaths
59connectionInfoForConfig (RemoteInterpreterConfig remoteNodeId remoteDBName _) = RemoteProcessConnectionInfo remoteDBName remoteNodeId outputNotificationCallback
61headNameForConfig :: InterpreterConfig -> HeadName
62headNameForConfig (LocalInterpreterConfig _ headn _) = headn
63headNameForConfig (RemoteInterpreterConfig _ _ headn) = headn
66ghcPkgPathsForConfig :: InterpreterConfig -> [GhcPkgPath]
67ghcPkgPathsForConfig (LocalInterpreterConfig _ _ paths) = paths
68ghcPkgPathsForConfig _ = error "Clients cannot configure remote ghc package paths."
71errDie :: String -> IO ()
72errDie err = hPutStrLn stderr err >> exitFailure
74#ifndef VERSION_project_m36
75#error VERSION_project_m36 is not defined
79 putStrLn $ "Project:M36 TutorialD Interpreter " ++ VERSION_project_m36
80 putStrLn "Type \":help\" for more information."
81 putStrLn "A full tutorial is available at:"
82 putStrLn "https://github.com/agentm/project-m36/blob/master/docs/tutd_tutorial.markdown"
86 interpreterConfig <- execParser opts
87 let connInfo = connectionInfoForConfig interpreterConfig
88 dbconn <- connectProjectM36 connInfo
91 errDie ("Failed to create database connection: " ++ show err)
93 let connHeadName = headNameForConfig interpreterConfig
94 eSessionId <- createSessionAtHead conn connHeadName
96 Left err -> errDie ("Failed to create database session at \"" ++ show connHeadName ++ "\": " ++ show err)
99 _ <- reprLoop interpreterConfig sessionId conn
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