core: output messages and events while executing the CLI command passed via -e option (#3683)

* core: output messages and events while executing the CLI command passed via -e option

* option

* add option
This commit is contained in:
Evgeny Poberezkin
2024-01-20 14:59:13 +00:00
committed by GitHub
parent 5aa4b7687e
commit c65a17fccb
6 changed files with 54 additions and 19 deletions
+1
View File
@@ -197,6 +197,7 @@ mobileChatOpts dbFilePrefix =
deviceName = Nothing,
chatCmd = "",
chatCmdDelay = 3,
chatCmdLog = CCLNone,
chatServerPort = Nothing,
optFilesFolder = Nothing,
showReactions = False,
+21
View File
@@ -8,6 +8,7 @@
module Simplex.Chat.Options
( ChatOpts (..),
CoreChatOpts (..),
ChatCmdLog (..),
chatOptsP,
coreChatOptsP,
getChatOpts,
@@ -37,6 +38,7 @@ data ChatOpts = ChatOpts
deviceName :: Maybe Text,
chatCmd :: String,
chatCmdDelay :: Int,
chatCmdLog :: ChatCmdLog,
chatServerPort :: Maybe String,
optFilesFolder :: Maybe FilePath,
showReactions :: Bool,
@@ -62,6 +64,9 @@ data CoreChatOpts = CoreChatOpts
highlyAvailable :: Bool
}
data ChatCmdLog = CCLAll | CCLMessages | CCLNone
deriving (Eq)
agentLogLevel :: ChatLogLevel -> LogLevel
agentLogLevel = \case
CLLDebug -> LogDebug
@@ -229,6 +234,14 @@ chatOptsP appDir defaultDbFileName = do
<> value 3
<> showDefault
)
chatCmdLog <-
option
parseChatCmdLog
( long "execute-log"
<> metavar "EXEC_LOG"
<> help "Log during command execution: all, messages, none (default)"
<> value CCLNone
)
chatServerPort <-
option
parseServerPort
@@ -288,6 +301,7 @@ chatOptsP appDir defaultDbFileName = do
deviceName,
chatCmd,
chatCmdDelay,
chatCmdLog,
chatServerPort,
optFilesFolder,
showReactions,
@@ -327,6 +341,13 @@ parseLogLevel = eitherReader $ \case
"important" -> Right CLLImportant
_ -> Left "Invalid log level"
parseChatCmdLog :: ReadM ChatCmdLog
parseChatCmdLog = eitherReader $ \case
"all" -> Right CCLAll
"messages" -> Right CCLMessages
"none" -> Right CCLNone
_ -> Left "Invalid chat command log level"
getChatOpts :: FilePath -> FilePath -> IO ChatOpts
getChatOpts appDir defaultDbFileName =
execParser $