diff --git a/ChatOptions.hs b/ChatOptions.hs index 0a7ff89f09..0940c34b8f 100644 --- a/ChatOptions.hs +++ b/ChatOptions.hs @@ -2,10 +2,10 @@ module ChatOptions (getChatOpts, ChatOpts (..)) where -import qualified Data.Attoparsec.ByteString.Char8 as A import qualified Data.ByteString.Char8 as B import Options.Applicative import Simplex.Messaging.Agent.Transmission (SMPServer (..), smpServerP) +import Simplex.Messaging.Parsers (parseAll) import System.FilePath (combine) import System.Info (os) import Types @@ -58,7 +58,7 @@ chatOpts appDir = | otherwise = TermModeEditor parseSMPServer :: ReadM SMPServer -parseSMPServer = eitherReader $ A.parseOnly (smpServerP <* A.endOfInput) . B.pack +parseSMPServer = eitherReader $ parseAll smpServerP . B.pack parseTermMode :: ReadM TermMode parseTermMode = maybeReader $ \case diff --git a/Main.hs b/Main.hs index ac33b81e50..bc2c1c198f 100644 --- a/Main.hs +++ b/Main.hs @@ -26,6 +26,7 @@ import Simplex.Messaging.Agent.Client (AgentClient (..)) import Simplex.Messaging.Agent.Env.SQLite import Simplex.Messaging.Agent.Transmission import Simplex.Messaging.Client (smpDefaultConfig) +import Simplex.Messaging.Parsers (parseAll) import Simplex.Messaging.Util (bshow, raceAny_) import System.Directory (getAppUserDataDirectory) import System.Exit (exitFailure) @@ -124,7 +125,7 @@ main = do t <- getChatClient smpServer user ct <- newChatTerminal (tbqSize cfg) user termMode -- setLogLevel LogInfo -- LogError - -- withGlobalLogging logCfg $ + -- withGlobalLogging logCfg $ do env <- newSMPAgentEnv cfg {dbFile = dbFileName} dogFoodChat t ct env @@ -172,7 +173,7 @@ newChatClient qSize smpServer name = do receiveFromChatTerm :: ChatClient -> ChatTerminal -> IO () receiveFromChatTerm t ct = forever $ do atomically (readTBQueue $ inputQ ct) - >>= processOrError . A.parseOnly (chatCommandP <* A.endOfInput) + >>= processOrError . parseAll chatCommandP where processOrError = \case Left err -> atomically . writeTBQueue (outQ t) . ErrorInput $ B.pack err