mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-28 00:44:27 +00:00
core: fix parsing multiple servers passed as cli argument (#2549)
This commit is contained in:
+3
-3
@@ -355,9 +355,9 @@ processChatCommand = \case
|
||||
asks currentUser >>= readTVarIO >>= \case
|
||||
Nothing -> throwChatError CENoActiveUser
|
||||
Just user -> do
|
||||
smpServers <- withStore' (`getProtocolServers` user)
|
||||
servers <- withStore' (`getProtocolServers` user)
|
||||
cfg <- asks config
|
||||
pure (activeAgentServers cfg protocol smpServers, smpServers)
|
||||
pure (activeAgentServers cfg protocol servers, servers)
|
||||
| otherwise = do
|
||||
defServers <- asks $ defaultServers . config
|
||||
pure (cfgServers protocol defServers, [])
|
||||
@@ -4989,7 +4989,7 @@ chatCommandP =
|
||||
onOffP = ("on" $> True) <|> ("off" $> False)
|
||||
profileNames = (,) <$> displayName <*> fullNameP
|
||||
newUserP = do
|
||||
sameServers <- "same_smp=" *> onOffP <* A.space <|> pure False
|
||||
sameServers <- "same_servers=" *> onOffP <* A.space <|> pure False
|
||||
(cName, fullName) <- profileNames
|
||||
let profile = Just Profile {displayName = cName, fullName, image = Nothing, contactLink = Nothing, preferences = Nothing}
|
||||
pure NewUser {profile, sameServers, pastTimestamp = False}
|
||||
|
||||
@@ -25,7 +25,7 @@ import Simplex.Chat.Controller (ChatLogLevel (..), updateStr, versionNumber, ver
|
||||
import Simplex.Messaging.Client (NetworkConfig (..), defaultNetworkConfig)
|
||||
import Simplex.Messaging.Encoding.String
|
||||
import Simplex.Messaging.Parsers (parseAll)
|
||||
import Simplex.Messaging.Protocol (ProtocolTypeI, ProtoServerWithAuth, SMPServerWithAuth, XFTPServerWithAuth)
|
||||
import Simplex.Messaging.Protocol (ProtoServerWithAuth, ProtocolTypeI, SMPServerWithAuth, XFTPServerWithAuth)
|
||||
import Simplex.Messaging.Transport.Client (SocksProxy, defaultSocksProxy)
|
||||
import System.FilePath (combine)
|
||||
|
||||
@@ -88,7 +88,11 @@ coreChatOptsP appDir defaultDbFileName = do
|
||||
( long "server"
|
||||
<> short 's'
|
||||
<> metavar "SERVER"
|
||||
<> help "Semicolon-separated list of SMP server(s) to use (each server can have more than one hostname)"
|
||||
<> help
|
||||
( ("Space-separated list of SMP server(s) to use (each server can have more than one hostname)." <> "\n")
|
||||
<> ("If you pass multiple servers, surround the entire list in quotes." <> "\n")
|
||||
<> "Examples: smp1.example.com, \"smp1.example.com smp2.example.com smp3.example.com\""
|
||||
)
|
||||
<> value []
|
||||
)
|
||||
xftpServers <-
|
||||
@@ -96,7 +100,11 @@ coreChatOptsP appDir defaultDbFileName = do
|
||||
parseProtocolServers
|
||||
( long "xftp-server"
|
||||
<> metavar "SERVER"
|
||||
<> help "Semicolon-separated list of XFTP server(s) to use (each server can have more than one hostname)"
|
||||
<> help
|
||||
( ("Space-separated list of XFTP server(s) to use (each server can have more than one hostname)." <> "\n")
|
||||
<> ("If you pass multiple servers, surround the entire list in quotes." <> "\n")
|
||||
<> "Examples: xftp1.example.com, \"xftp1.example.com xftp2.example.com xftp3.example.com\""
|
||||
)
|
||||
<> value []
|
||||
)
|
||||
socksProxy <-
|
||||
@@ -270,7 +278,7 @@ serverPortP :: A.Parser (Maybe String)
|
||||
serverPortP = Just . B.unpack <$> A.takeWhile A.isDigit
|
||||
|
||||
protocolServersP :: ProtocolTypeI p => A.Parser [ProtoServerWithAuth p]
|
||||
protocolServersP = strP `A.sepBy1` A.char ';'
|
||||
protocolServersP = strP `A.sepBy1` A.char ' '
|
||||
|
||||
parseLogLevel :: ReadM ChatLogLevel
|
||||
parseLogLevel = eitherReader $ \case
|
||||
|
||||
Reference in New Issue
Block a user