mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-06-04 21:12:05 +00:00
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:
committed by
GitHub
parent
5aa4b7687e
commit
c65a17fccb
@@ -197,6 +197,7 @@ mobileChatOpts dbFilePrefix =
|
||||
deviceName = Nothing,
|
||||
chatCmd = "",
|
||||
chatCmdDelay = 3,
|
||||
chatCmdLog = CCLNone,
|
||||
chatServerPort = Nothing,
|
||||
optFilesFolder = Nothing,
|
||||
showReactions = False,
|
||||
|
||||
@@ -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 $
|
||||
|
||||
Reference in New Issue
Block a user