core: cli remote control help section (#3445)

This commit is contained in:
Evgeny Poberezkin 2023-11-24 10:48:14 +00:00 committed by GitHub
parent 74e80eb348
commit b1cf1656a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 4 deletions

View File

@ -6073,8 +6073,9 @@ chatCommandP =
("/help groups" <|> "/help group" <|> "/hg") $> ChatHelp HSGroups, ("/help groups" <|> "/help group" <|> "/hg") $> ChatHelp HSGroups,
("/help contacts" <|> "/help contact" <|> "/hc") $> ChatHelp HSContacts, ("/help contacts" <|> "/help contact" <|> "/hc") $> ChatHelp HSContacts,
("/help address" <|> "/ha") $> ChatHelp HSMyAddress, ("/help address" <|> "/ha") $> ChatHelp HSMyAddress,
"/help incognito" $> ChatHelp HSIncognito, ("/help incognito" <|> "/hi") $> ChatHelp HSIncognito,
("/help messages" <|> "/hm") $> ChatHelp HSMessages, ("/help messages" <|> "/hm") $> ChatHelp HSMessages,
("/help remote" <|> "/hr") $> ChatHelp HSRemote,
("/help settings" <|> "/hs") $> ChatHelp HSSettings, ("/help settings" <|> "/hs") $> ChatHelp HSSettings,
("/help db" <|> "/hd") $> ChatHelp HSDatabase, ("/help db" <|> "/hd") $> ChatHelp HSDatabase,
("/help" <|> "/h") $> ChatHelp HSMain, ("/help" <|> "/h") $> ChatHelp HSMain,
@ -6181,7 +6182,6 @@ chatCommandP =
"/set disappear " *> (SetUserTimedMessages <$> (("yes" $> True) <|> ("no" $> False))), "/set disappear " *> (SetUserTimedMessages <$> (("yes" $> True) <|> ("no" $> False))),
("/incognito" <* optional (A.space *> onOffP)) $> ChatHelp HSIncognito, ("/incognito" <* optional (A.space *> onOffP)) $> ChatHelp HSIncognito,
"/set device name " *> (SetLocalDeviceName <$> textP), "/set device name " *> (SetLocalDeviceName <$> textP),
-- "/create remote host" $> CreateRemoteHost,
"/list remote hosts" $> ListRemoteHosts, "/list remote hosts" $> ListRemoteHosts,
"/switch remote host " *> (SwitchRemoteHost <$> ("local" $> Nothing <|> (Just <$> A.decimal))), "/switch remote host " *> (SwitchRemoteHost <$> ("local" $> Nothing <|> (Just <$> A.decimal))),
"/start remote host " *> (StartRemoteHost <$> ("new" $> Nothing <|> (Just <$> ((,) <$> A.decimal <*> (" multicast=" *> onOffP <|> pure False))))), "/start remote host " *> (StartRemoteHost <$> ("new" $> Nothing <|> (Just <$> ((,) <$> A.decimal <*> (" multicast=" *> onOffP <|> pure False))))),

View File

@ -203,7 +203,7 @@ data ChatController = ChatController
contactMergeEnabled :: TVar Bool contactMergeEnabled :: TVar Bool
} }
data HelpSection = HSMain | HSFiles | HSGroups | HSContacts | HSMyAddress | HSIncognito | HSMarkdown | HSMessages | HSSettings | HSDatabase data HelpSection = HSMain | HSFiles | HSGroups | HSContacts | HSMyAddress | HSIncognito | HSMarkdown | HSMessages | HSRemote | HSSettings | HSDatabase
deriving (Show) deriving (Show)
data ChatCommand data ChatCommand

View File

@ -10,6 +10,7 @@ module Simplex.Chat.Help
myAddressHelpInfo, myAddressHelpInfo,
incognitoHelpInfo, incognitoHelpInfo,
messagesHelpInfo, messagesHelpInfo,
remoteHelpInfo,
markdownInfo, markdownInfo,
settingsInfo, settingsInfo,
databaseHelpInfo, databaseHelpInfo,
@ -87,7 +88,7 @@ chatHelpInfo =
green "Create your address: " <> highlight "/address", green "Create your address: " <> highlight "/address",
"", "",
green "Other commands:", green "Other commands:",
indent <> highlight "/help <topic> " <> " - help on: " <> listHighlight ["groups", "contacts", "messages", "files", "address", "settings", "db"], indent <> highlight "/help <topic> " <> " - help on: " <> listHighlight ["groups", "contacts", "messages", "files", "address", "incognito", "remote", "settings", "db"],
indent <> highlight "/profile " <> " - show / update user profile", indent <> highlight "/profile " <> " - show / update user profile",
indent <> highlight "/delete <contact>" <> " - delete contact and all messages with them", indent <> highlight "/delete <contact>" <> " - delete contact and all messages with them",
indent <> highlight "/chats " <> " - most recent chats", indent <> highlight "/chats " <> " - most recent chats",
@ -272,6 +273,34 @@ messagesHelpInfo =
indent <> highlight "! #team (hi) <new msg> " <> " - to edit your message in the group #team" indent <> highlight "! #team (hi) <new msg> " <> " - to edit your message in the group #team"
] ]
remoteHelpInfo :: [StyledString]
remoteHelpInfo =
map
styleMarkdown
[ green "Remote control",
"You can use CLI as a remote controller for a mobile app or as a remote host for a desktop app (or another CLI).",
"For example, you can run CLI on a server and use it from a desktop computer, connecting via SSH port forwarding.",
"",
indent <> highlight "/set device name <name> " <> " - set CLI name for remote connections",
"",
green "Using as remote controller",
indent <> highlight "/start remote host new " <> " - pair and connect a new remote host",
indent <> highlight "/start remote host <id> [multicast=on] " <> " - start connection with a known (paired) remote host",
indent <> highlight "/stop remote host new " <> " - cancel pairing with a new remote host",
indent <> highlight "/stop remote host <id> " <> " - stop connection with connected remote host",
indent <> highlight "/switch remote host local " <> " - switch to using local database",
indent <> highlight "/switch remote host <id> " <> " - switch to connected remote host",
indent <> highlight "/list remote hosts " <> " - list known remote hosts",
indent <> highlight "/delete remote host <id> " <> " - delete (unpair) known remote hosts - also deletes all host files from controller",
"",
green "Using as remote host",
indent <> highlight "/connect remote ctrl <session_address> " <> " - connect to remote controller via the adress from /start remote host",
indent <> highlight "/stop remote ctrl " <> " - stop connection with remote controller",
indent <> highlight "/find remote ctrl " <> " - find known remote controller on the local network (it should be started with multicast=on)",
indent <> highlight "/list remote ctrls " <> " - list known remote controllers",
indent <> highlight "/delete remote ctrl <id> " <> " - delete known remote controller"
]
markdownInfo :: [StyledString] markdownInfo :: [StyledString]
markdownInfo = markdownInfo =
map map

View File

@ -136,6 +136,7 @@ responseToView hu@(currentRH, user_) ChatConfig {logLevel, showReactions, showRe
HSIncognito -> incognitoHelpInfo HSIncognito -> incognitoHelpInfo
HSMessages -> messagesHelpInfo HSMessages -> messagesHelpInfo
HSMarkdown -> markdownInfo HSMarkdown -> markdownInfo
HSRemote -> remoteHelpInfo
HSSettings -> settingsInfo HSSettings -> settingsInfo
HSDatabase -> databaseHelpInfo HSDatabase -> databaseHelpInfo
CRWelcome user -> chatWelcome user CRWelcome user -> chatWelcome user
@ -310,6 +311,7 @@ responseToView hu@(currentRH, user_) ChatConfig {logLevel, showReactions, showRe
[ "remote controller " <> sShow remoteCtrlId <> " found: " [ "remote controller " <> sShow remoteCtrlId <> " found: "
<> maybe (deviceName <> "not compatible") (\info -> viewRemoteCtrl info appVersion compatible) ctrlAppInfo_ <> maybe (deviceName <> "not compatible") (\info -> viewRemoteCtrl info appVersion compatible) ctrlAppInfo_
] ]
<> [ "use " <> highlight ("/confirm remote ctrl " <> show remoteCtrlId) <> " to connect" | isJust ctrlAppInfo_ && compatible]
where where
deviceName = if T.null ctrlDeviceName then "" else plain ctrlDeviceName <> ", " deviceName = if T.null ctrlDeviceName then "" else plain ctrlDeviceName <> ", "
CRRemoteCtrlConnecting {remoteCtrl_, ctrlAppInfo, appVersion} -> CRRemoteCtrlConnecting {remoteCtrl_, ctrlAppInfo, appVersion} ->

View File

@ -460,6 +460,7 @@ startRemoteDiscover mobile desktop = do
mobile ##> "/find remote ctrl" mobile ##> "/find remote ctrl"
mobile <## "ok" mobile <## "ok"
mobile <## ("remote controller 1 found: My desktop, v" <> versionNumber) mobile <## ("remote controller 1 found: My desktop, v" <> versionNumber)
mobile <## "use /confirm remote ctrl 1 to connect"
mobile ##> "/confirm remote ctrl 1" mobile ##> "/confirm remote ctrl 1"
mobile <## ("connecting remote controller 1: My desktop, v" <> versionNumber) mobile <## ("connecting remote controller 1: My desktop, v" <> versionNumber)