mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2025-06-28 20:29:53 +00:00
cli: amend help messages (#2447)
* cli: amend help messages * print servers on multiple lines * correction * fix tests
This commit is contained in:
parent
761fbf7757
commit
b49f0d211b
3 changed files with 29 additions and 23 deletions
|
@ -270,7 +270,8 @@ settingsInfo =
|
||||||
[ green "Chat settings:",
|
[ green "Chat settings:",
|
||||||
indent <> highlight "/incognito on/off " <> " - enable/disable incognito mode",
|
indent <> highlight "/incognito on/off " <> " - enable/disable incognito mode",
|
||||||
indent <> highlight "/network " <> " - show / set network access options",
|
indent <> highlight "/network " <> " - show / set network access options",
|
||||||
indent <> highlight "/smp " <> " - show / set custom SMP servers",
|
indent <> highlight "/smp " <> " - show / set configured SMP servers",
|
||||||
|
indent <> highlight "/xftp " <> " - show / set configured XFTP servers",
|
||||||
indent <> highlight "/info <contact> " <> " - information about contact connection",
|
indent <> highlight "/info <contact> " <> " - information about contact connection",
|
||||||
indent <> highlight "/info #<group> <member> " <> " - information about member connection",
|
indent <> highlight "/info #<group> <member> " <> " - information about member connection",
|
||||||
indent <> highlight "/(un)mute <contact> " <> " - (un)mute contact, the last messages can be printed with /tail command",
|
indent <> highlight "/(un)mute <contact> " <> " - (un)mute contact, the last messages can be printed with /tail command",
|
||||||
|
|
|
@ -49,7 +49,7 @@ import qualified Simplex.Messaging.Crypto as C
|
||||||
import Simplex.Messaging.Encoding
|
import Simplex.Messaging.Encoding
|
||||||
import Simplex.Messaging.Encoding.String
|
import Simplex.Messaging.Encoding.String
|
||||||
import Simplex.Messaging.Parsers (dropPrefix, taggedObjectJSON)
|
import Simplex.Messaging.Parsers (dropPrefix, taggedObjectJSON)
|
||||||
import Simplex.Messaging.Protocol (AProtoServerWithAuth (..), AProtocolType, ProtocolServer (..), ProtocolTypeI, SProtocolType (..))
|
import Simplex.Messaging.Protocol (AProtoServerWithAuth (..), AProtocolType, ProtocolServer (..), ProtoServerWithAuth, ProtocolTypeI, SProtocolType (..))
|
||||||
import qualified Simplex.Messaging.Protocol as SMP
|
import qualified Simplex.Messaging.Protocol as SMP
|
||||||
import Simplex.Messaging.Transport.Client (TransportHost (..))
|
import Simplex.Messaging.Transport.Client (TransportHost (..))
|
||||||
import Simplex.Messaging.Util (bshow, tshow)
|
import Simplex.Messaging.Util (bshow, tshow)
|
||||||
|
@ -829,18 +829,17 @@ viewUserPrivacy User {userId} User {userId = userId', localDisplayName = n', sho
|
||||||
"profile is " <> if isJust viewPwdHash then "hidden" else "visible"
|
"profile is " <> if isJust viewPwdHash then "hidden" else "visible"
|
||||||
]
|
]
|
||||||
|
|
||||||
-- TODO make more generic messages or split
|
|
||||||
viewUserServers :: AUserProtoServers -> Bool -> [StyledString]
|
viewUserServers :: AUserProtoServers -> Bool -> [StyledString]
|
||||||
viewUserServers (AUPS UserProtoServers {serverProtocol = p, protoServers}) testView =
|
viewUserServers (AUPS UserProtoServers {serverProtocol = p, protoServers, presetServers}) testView =
|
||||||
if testView
|
customServers <>
|
||||||
then [customServers]
|
if testView
|
||||||
else
|
then []
|
||||||
[ customServers,
|
else
|
||||||
"",
|
[ "",
|
||||||
"use " <> highlight (srvCmd <> " test <srv>") <> " to test " <> pName <> " server connection",
|
"use " <> highlight (srvCmd <> " test <srv>") <> " to test " <> pName <> " server connection",
|
||||||
"use " <> highlight (srvCmd <> " set <srv1[,srv2,...]>") <> " to switch to custom " <> pName <> " servers",
|
"use " <> highlight (srvCmd <> " <srv1[,srv2,...]>") <> " to configure " <> pName <> " servers",
|
||||||
"use " <> highlight (srvCmd <> " default") <> " to remove custom " <> pName <> " servers and use default"
|
"use " <> highlight (srvCmd <> " default") <> " to remove configured " <> pName <> " servers and use presets"
|
||||||
]
|
]
|
||||||
<> case p of
|
<> case p of
|
||||||
SPSMP -> ["(chat option " <> highlight' "-s" <> " (" <> highlight' "--server" <> ") has precedence over saved SMP servers for chat session)"]
|
SPSMP -> ["(chat option " <> highlight' "-s" <> " (" <> highlight' "--server" <> ") has precedence over saved SMP servers for chat session)"]
|
||||||
SPXFTP -> ["(chat option " <> highlight' "-xftp-servers" <> " has precedence over saved XFTP servers for chat session)"]
|
SPXFTP -> ["(chat option " <> highlight' "-xftp-servers" <> " has precedence over saved XFTP servers for chat session)"]
|
||||||
|
@ -849,8 +848,8 @@ viewUserServers (AUPS UserProtoServers {serverProtocol = p, protoServers}) testV
|
||||||
pName = protocolName p
|
pName = protocolName p
|
||||||
customServers =
|
customServers =
|
||||||
if null protoServers
|
if null protoServers
|
||||||
then "no custom SMP servers saved"
|
then ("no " <> pName <> " servers saved, using presets: ") : viewServers id presetServers
|
||||||
else viewServers protoServers
|
else viewServers (\ServerCfg {server} -> server) protoServers
|
||||||
|
|
||||||
protocolName :: ProtocolTypeI p => SProtocolType p -> StyledString
|
protocolName :: ProtocolTypeI p => SProtocolType p -> StyledString
|
||||||
protocolName = plain . map toUpper . T.unpack . decodeLatin1 . strEncode
|
protocolName = plain . map toUpper . T.unpack . decodeLatin1 . strEncode
|
||||||
|
@ -918,8 +917,8 @@ viewConnectionStats ConnectionStats {rcvServers, sndServers} =
|
||||||
["receiving messages via: " <> viewServerHosts rcvServers | not $ null rcvServers]
|
["receiving messages via: " <> viewServerHosts rcvServers | not $ null rcvServers]
|
||||||
<> ["sending messages via: " <> viewServerHosts sndServers | not $ null sndServers]
|
<> ["sending messages via: " <> viewServerHosts sndServers | not $ null sndServers]
|
||||||
|
|
||||||
viewServers :: ProtocolTypeI p => NonEmpty (ServerCfg p) -> StyledString
|
viewServers :: ProtocolTypeI p => (a -> ProtoServerWithAuth p) -> NonEmpty a -> [StyledString]
|
||||||
viewServers = plain . intercalate ", " . map (B.unpack . strEncode . (\ServerCfg {server} -> server)) . L.toList
|
viewServers f = map (plain . B.unpack . strEncode . f) . L.toList
|
||||||
|
|
||||||
viewServerHosts :: [SMPServer] -> StyledString
|
viewServerHosts :: [SMPServer] -> StyledString
|
||||||
viewServerHosts = plain . intercalate ", " . map showSMPServer
|
viewServerHosts = plain . intercalate ", " . map showSMPServer
|
||||||
|
|
|
@ -518,7 +518,8 @@ testGetSetSMPServers =
|
||||||
alice #$> ("/smp smp://1234-w==:password@smp1.example.im", id, "ok")
|
alice #$> ("/smp smp://1234-w==:password@smp1.example.im", id, "ok")
|
||||||
alice #$> ("/smp", id, "smp://1234-w==:password@smp1.example.im")
|
alice #$> ("/smp", id, "smp://1234-w==:password@smp1.example.im")
|
||||||
alice #$> ("/smp smp://2345-w==@smp2.example.im;smp://3456-w==@smp3.example.im:5224", id, "ok")
|
alice #$> ("/smp smp://2345-w==@smp2.example.im;smp://3456-w==@smp3.example.im:5224", id, "ok")
|
||||||
alice #$> ("/smp", id, "smp://2345-w==@smp2.example.im, smp://3456-w==@smp3.example.im:5224")
|
alice #$> ("/smp", id, "smp://2345-w==@smp2.example.im")
|
||||||
|
alice <## "smp://3456-w==@smp3.example.im:5224"
|
||||||
alice #$> ("/smp default", id, "ok")
|
alice #$> ("/smp default", id, "ok")
|
||||||
alice #$> ("/smp", id, "smp://LcJUMfVhwD8yxjAiSaDzzGF3-kLG4Uh0Fl_ZIjrRwjI=:server_password@localhost:7001")
|
alice #$> ("/smp", id, "smp://LcJUMfVhwD8yxjAiSaDzzGF3-kLG4Uh0Fl_ZIjrRwjI=:server_password@localhost:7001")
|
||||||
|
|
||||||
|
@ -547,7 +548,8 @@ testGetSetXFTPServers =
|
||||||
alice #$> ("/xftp xftp://1234-w==:password@xftp1.example.im", id, "ok")
|
alice #$> ("/xftp xftp://1234-w==:password@xftp1.example.im", id, "ok")
|
||||||
alice #$> ("/xftp", id, "xftp://1234-w==:password@xftp1.example.im")
|
alice #$> ("/xftp", id, "xftp://1234-w==:password@xftp1.example.im")
|
||||||
alice #$> ("/xftp xftp://2345-w==@xftp2.example.im;xftp://3456-w==@xftp3.example.im:5224", id, "ok")
|
alice #$> ("/xftp xftp://2345-w==@xftp2.example.im;xftp://3456-w==@xftp3.example.im:5224", id, "ok")
|
||||||
alice #$> ("/xftp", id, "xftp://2345-w==@xftp2.example.im, xftp://3456-w==@xftp3.example.im:5224")
|
alice #$> ("/xftp", id, "xftp://2345-w==@xftp2.example.im")
|
||||||
|
alice <## "xftp://3456-w==@xftp3.example.im:5224"
|
||||||
alice #$> ("/xftp default", id, "ok")
|
alice #$> ("/xftp default", id, "ok")
|
||||||
alice #$> ("/xftp", id, "xftp://LcJUMfVhwD8yxjAiSaDzzGF3-kLG4Uh0Fl_ZIjrRwjI=:server_password@localhost:7002")
|
alice #$> ("/xftp", id, "xftp://LcJUMfVhwD8yxjAiSaDzzGF3-kLG4Uh0Fl_ZIjrRwjI=:server_password@localhost:7002")
|
||||||
|
|
||||||
|
@ -1129,7 +1131,8 @@ testCreateUserDefaultServers =
|
||||||
testChat2 aliceProfile bobProfile $
|
testChat2 aliceProfile bobProfile $
|
||||||
\alice _ -> do
|
\alice _ -> do
|
||||||
alice #$> ("/smp smp://2345-w==@smp2.example.im;smp://3456-w==@smp3.example.im:5224", id, "ok")
|
alice #$> ("/smp smp://2345-w==@smp2.example.im;smp://3456-w==@smp3.example.im:5224", id, "ok")
|
||||||
alice #$> ("/smp", id, "smp://2345-w==@smp2.example.im, smp://3456-w==@smp3.example.im:5224")
|
alice #$> ("/smp", id, "smp://2345-w==@smp2.example.im")
|
||||||
|
alice <## "smp://3456-w==@smp3.example.im:5224"
|
||||||
|
|
||||||
alice ##> "/create user alisa"
|
alice ##> "/create user alisa"
|
||||||
showActiveUser alice "alisa"
|
showActiveUser alice "alisa"
|
||||||
|
@ -1139,7 +1142,8 @@ testCreateUserDefaultServers =
|
||||||
-- with same_smp=off
|
-- with same_smp=off
|
||||||
alice ##> "/user alice"
|
alice ##> "/user alice"
|
||||||
showActiveUser alice "alice (Alice)"
|
showActiveUser alice "alice (Alice)"
|
||||||
alice #$> ("/smp", id, "smp://2345-w==@smp2.example.im, smp://3456-w==@smp3.example.im:5224")
|
alice #$> ("/smp", id, "smp://2345-w==@smp2.example.im")
|
||||||
|
alice <## "smp://3456-w==@smp3.example.im:5224"
|
||||||
|
|
||||||
alice ##> "/create user same_smp=off alisa2"
|
alice ##> "/create user same_smp=off alisa2"
|
||||||
showActiveUser alice "alisa2"
|
showActiveUser alice "alisa2"
|
||||||
|
@ -1151,12 +1155,14 @@ testCreateUserSameServers =
|
||||||
testChat2 aliceProfile bobProfile $
|
testChat2 aliceProfile bobProfile $
|
||||||
\alice _ -> do
|
\alice _ -> do
|
||||||
alice #$> ("/smp smp://2345-w==@smp2.example.im;smp://3456-w==@smp3.example.im:5224", id, "ok")
|
alice #$> ("/smp smp://2345-w==@smp2.example.im;smp://3456-w==@smp3.example.im:5224", id, "ok")
|
||||||
alice #$> ("/smp", id, "smp://2345-w==@smp2.example.im, smp://3456-w==@smp3.example.im:5224")
|
alice #$> ("/smp", id, "smp://2345-w==@smp2.example.im")
|
||||||
|
alice <## "smp://3456-w==@smp3.example.im:5224"
|
||||||
|
|
||||||
alice ##> "/create user same_smp=on alisa"
|
alice ##> "/create user same_smp=on alisa"
|
||||||
showActiveUser alice "alisa"
|
showActiveUser alice "alisa"
|
||||||
|
|
||||||
alice #$> ("/smp", id, "smp://2345-w==@smp2.example.im, smp://3456-w==@smp3.example.im:5224")
|
alice #$> ("/smp", id, "smp://2345-w==@smp2.example.im")
|
||||||
|
alice <## "smp://3456-w==@smp3.example.im:5224"
|
||||||
|
|
||||||
testDeleteUser :: HasCallStack => FilePath -> IO ()
|
testDeleteUser :: HasCallStack => FilePath -> IO ()
|
||||||
testDeleteUser =
|
testDeleteUser =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue