mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-26 09:44:55 +00:00
refactor(cli): move display-name option to ChatOpts in CLI
This commit is contained in:
@@ -76,6 +76,7 @@ mkChatOpts BroadcastBotOpts {coreOptions} =
|
||||
ChatOpts
|
||||
{ coreOptions,
|
||||
deviceName = Nothing,
|
||||
displayName = Nothing,
|
||||
chatCmd = "",
|
||||
chatCmdDelay = 3,
|
||||
chatCmdLog = CCLNone,
|
||||
|
||||
@@ -85,6 +85,7 @@ mkChatOpts DirectoryOpts {coreOptions} =
|
||||
ChatOpts
|
||||
{ coreOptions,
|
||||
deviceName = Nothing,
|
||||
displayName = Nothing,
|
||||
chatCmd = "",
|
||||
chatCmdDelay = 3,
|
||||
chatCmdLog = CCLNone,
|
||||
|
||||
@@ -32,7 +32,7 @@ import Text.Read (readMaybe)
|
||||
import UnliftIO.Async
|
||||
|
||||
simplexChatCore :: ChatConfig -> ChatOpts -> (User -> ChatController -> IO ()) -> IO ()
|
||||
simplexChatCore cfg@ChatConfig {confirmMigrations, testView} opts@ChatOpts {coreOptions = CoreChatOpts {dbFilePrefix, dbKey, logAgent, displayName}} chat =
|
||||
simplexChatCore cfg@ChatConfig {confirmMigrations, testView} opts@ChatOpts {coreOptions = CoreChatOpts {dbFilePrefix, dbKey, logAgent}, displayName} chat =
|
||||
case logAgent of
|
||||
Just level -> do
|
||||
setLogLevel level
|
||||
|
||||
@@ -189,7 +189,6 @@ mobileChatOpts dbFilePrefix =
|
||||
CoreChatOpts
|
||||
{ dbFilePrefix,
|
||||
dbKey = "", -- for API database is already opened, and the key in options is not used
|
||||
displayName = Nothing,
|
||||
smpServers = [],
|
||||
xftpServers = [],
|
||||
simpleNetCfg = defaultSimpleNetCfg,
|
||||
@@ -203,6 +202,7 @@ mobileChatOpts dbFilePrefix =
|
||||
yesToUpMigrations = False
|
||||
},
|
||||
deviceName = Nothing,
|
||||
displayName = Nothing,
|
||||
chatCmd = "",
|
||||
chatCmdDelay = 3,
|
||||
chatCmdLog = CCLNone,
|
||||
|
||||
@@ -40,6 +40,7 @@ import Simplex.Chat.Types (ContactName)
|
||||
data ChatOpts = ChatOpts
|
||||
{ coreOptions :: CoreChatOpts,
|
||||
deviceName :: Maybe Text,
|
||||
displayName :: Maybe ContactName,
|
||||
chatCmd :: String,
|
||||
chatCmdDelay :: Int,
|
||||
chatCmdLog :: ChatCmdLog,
|
||||
@@ -57,7 +58,6 @@ data ChatOpts = ChatOpts
|
||||
data CoreChatOpts = CoreChatOpts
|
||||
{ dbFilePrefix :: String,
|
||||
dbKey :: ScrubbedBytes,
|
||||
displayName :: Maybe ContactName,
|
||||
smpServers :: [SMPServerWithAuth],
|
||||
xftpServers :: [XFTPServerWithAuth],
|
||||
simpleNetCfg :: SimpleNetCfg,
|
||||
@@ -101,13 +101,6 @@ coreChatOptsP appDir defaultDbFileName = do
|
||||
<> help "Database encryption key/pass-phrase"
|
||||
<> value ""
|
||||
)
|
||||
displayName <-
|
||||
optional $
|
||||
strOption
|
||||
( long "display-name"
|
||||
<> metavar "DISPLAY_NAME"
|
||||
<> help "Display name will be sent to your contacts when you connect and only stored on your device and you can change it later."
|
||||
)
|
||||
smpServers <-
|
||||
option
|
||||
parseProtocolServers
|
||||
@@ -253,7 +246,6 @@ coreChatOptsP appDir defaultDbFileName = do
|
||||
CoreChatOpts
|
||||
{ dbFilePrefix,
|
||||
dbKey,
|
||||
displayName,
|
||||
smpServers,
|
||||
xftpServers,
|
||||
simpleNetCfg =
|
||||
@@ -296,6 +288,13 @@ chatOptsP appDir defaultDbFileName = do
|
||||
<> metavar "DEVICE"
|
||||
<> help "Device name to use in connections with remote hosts and controller"
|
||||
)
|
||||
displayName <-
|
||||
optional $
|
||||
strOption
|
||||
( long "display-name"
|
||||
<> metavar "DISPLAY_NAME"
|
||||
<> help "Display name will be sent to your contacts when you connect and only stored on your device and you can change it later."
|
||||
)
|
||||
chatCmd <-
|
||||
strOption
|
||||
( long "execute"
|
||||
@@ -385,6 +384,7 @@ chatOptsP appDir defaultDbFileName = do
|
||||
pure
|
||||
ChatOpts
|
||||
{ coreOptions,
|
||||
displayName,
|
||||
deviceName,
|
||||
chatCmd,
|
||||
chatCmdDelay,
|
||||
|
||||
@@ -74,6 +74,7 @@ testOpts =
|
||||
ChatOpts
|
||||
{ coreOptions = testCoreOpts,
|
||||
deviceName = Nothing,
|
||||
displayName = Nothing,
|
||||
chatCmd = "",
|
||||
chatCmdDelay = 3,
|
||||
chatCmdLog = CCLNone,
|
||||
|
||||
@@ -223,9 +223,9 @@ testMultiWordProfileNames =
|
||||
alice #> "@'Cath J' hi"
|
||||
cath <# "'Alice Jones'> hi"
|
||||
where
|
||||
aliceProfile' = baseProfile {displayName = "Alice Jones"}
|
||||
bobProfile' = baseProfile {displayName = "Bob James"}
|
||||
cathProfile' = baseProfile {displayName = "Cath Johnson"}
|
||||
aliceProfile' = (baseProfile :: Profile) {displayName = "Alice Jones"}
|
||||
bobProfile' = (baseProfile :: Profile) {displayName = "Bob James"}
|
||||
cathProfile' = (baseProfile :: Profile) {displayName = "Cath Johnson"}
|
||||
baseProfile = Profile {displayName = "", fullName = "", image = Nothing, contactLink = Nothing, preferences = defaultPrefs}
|
||||
|
||||
testUserContactLink :: HasCallStack => FilePath -> IO ()
|
||||
|
||||
Reference in New Issue
Block a user