add version command (#123)
* Add /version and /v flags * Move version info from C Chat.Help to Chat.View * Move version string, use it in Main startup * use "SimpleX Chat" consistently Co-authored-by: TheTaoOfSu <TheTaoOfSu@protonmail.com>
This commit is contained in:
1 parent
deaea44024
commit
800a4f90bf
5 files changed
+14
-2
No files matched your search
@@ -6,6 +6,7 @@
|
|||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
import Simplex.Chat
|
import Simplex.Chat
|
||||||
|
import Simplex.Chat.Controller (versionNumber)
|
||||||
import Simplex.Chat.Options
|
import Simplex.Chat.Options
|
||||||
import System.Directory (getAppUserDataDirectory)
|
import System.Directory (getAppUserDataDirectory)
|
||||||
import System.Terminal (withTerminal)
|
import System.Terminal (withTerminal)
|
||||||
@@ -20,7 +21,7 @@ welcomeGetOpts :: IO ChatOpts
|
|||||||
welcomeGetOpts = do
|
welcomeGetOpts = do
|
||||||
appDir <- getAppUserDataDirectory "simplex"
|
appDir <- getAppUserDataDirectory "simplex"
|
||||||
opts@ChatOpts {dbFile} <- getChatOpts appDir
|
opts@ChatOpts {dbFile} <- getChatOpts appDir
|
||||||
putStrLn "SimpleX chat prototype v0.4.0"
|
putStrLn $ "SimpleX Chat v" ++ versionNumber
|
||||||
putStrLn $ "db: " <> dbFile <> ".chat.db, " <> dbFile <> ".agent.db"
|
putStrLn $ "db: " <> dbFile <> ".chat.db, " <> dbFile <> ".agent.db"
|
||||||
putStrLn "type \"/help\" or \"/h\" for usage info"
|
putStrLn "type \"/help\" or \"/h\" for usage info"
|
||||||
pure opts
|
pure opts
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ data ChatCommand
|
|||||||
| UpdateProfile Profile
|
| UpdateProfile Profile
|
||||||
| ShowProfile
|
| ShowProfile
|
||||||
| QuitChat
|
| QuitChat
|
||||||
|
| ShowVersion
|
||||||
deriving (Show)
|
deriving (Show)
|
||||||
|
|
||||||
defaultChatConfig :: ChatConfig
|
defaultChatConfig :: ChatConfig
|
||||||
@@ -317,6 +318,7 @@ processChatCommand user@User {userId, profile} = \case
|
|||||||
showUserProfileUpdated user user'
|
showUserProfileUpdated user user'
|
||||||
ShowProfile -> showUserProfile profile
|
ShowProfile -> showUserProfile profile
|
||||||
QuitChat -> liftIO exitSuccess
|
QuitChat -> liftIO exitSuccess
|
||||||
|
ShowVersion -> printToView clientVersionInfo
|
||||||
where
|
where
|
||||||
contactMember :: Contact -> [GroupMember] -> Maybe GroupMember
|
contactMember :: Contact -> [GroupMember] -> Maybe GroupMember
|
||||||
contactMember Contact {contactId} =
|
contactMember Contact {contactId} =
|
||||||
@@ -1110,6 +1112,7 @@ chatCommandP =
|
|||||||
<|> ("/profile " <|> "/p ") *> (UpdateProfile <$> userProfile)
|
<|> ("/profile " <|> "/p ") *> (UpdateProfile <$> userProfile)
|
||||||
<|> ("/profile" <|> "/p") $> ShowProfile
|
<|> ("/profile" <|> "/p") $> ShowProfile
|
||||||
<|> ("/quit" <|> "/q") $> QuitChat
|
<|> ("/quit" <|> "/q") $> QuitChat
|
||||||
|
<|> ("/version" <|> "/v") $> ShowVersion
|
||||||
where
|
where
|
||||||
displayName = safeDecodeUtf8 <$> (B.cons <$> A.satisfy refChar <*> A.takeTill (== ' '))
|
displayName = safeDecodeUtf8 <$> (B.cons <$> A.satisfy refChar <*> A.takeTill (== ' '))
|
||||||
refChar c = c > ' ' && c /= '#' && c /= '@'
|
refChar c = c > ' ' && c /= '#' && c /= '@'
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ import Simplex.Messaging.Agent.Store.SQLite (SQLiteStore)
|
|||||||
import System.IO (Handle)
|
import System.IO (Handle)
|
||||||
import UnliftIO.STM
|
import UnliftIO.STM
|
||||||
|
|
||||||
|
versionNumber :: String
|
||||||
|
versionNumber = "0.4.2"
|
||||||
|
|
||||||
data ChatConfig = ChatConfig
|
data ChatConfig = ChatConfig
|
||||||
{ agentConfig :: AgentConfig,
|
{ agentConfig :: AgentConfig,
|
||||||
dbPoolSize :: Int,
|
dbPoolSize :: Int,
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ chatHelpInfo :: [StyledString]
|
|||||||
chatHelpInfo =
|
chatHelpInfo =
|
||||||
map
|
map
|
||||||
styleMarkdown
|
styleMarkdown
|
||||||
[ highlight "Using SimpleX chat prototype",
|
[ highlight "Using SimpleX Chat",
|
||||||
"Follow these steps to set up a connection:",
|
"Follow these steps to set up a connection:",
|
||||||
"",
|
"",
|
||||||
green "Step 1: " <> highlight "/connect" <> " - Alice adds a contact.",
|
green "Step 1: " <> highlight "/connect" <> " - Alice adds a contact.",
|
||||||
@@ -58,6 +58,7 @@ chatHelpInfo =
|
|||||||
indent <> highlight "/profile <name> [<full_name>]" <> " - update user profile",
|
indent <> highlight "/profile <name> [<full_name>]" <> " - 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 "/markdown " <> " - show supported markdown syntax",
|
indent <> highlight "/markdown " <> " - show supported markdown syntax",
|
||||||
|
indent <> highlight "/version " <> " - show SimpleX Chat version",
|
||||||
indent <> highlight "/quit " <> " - quit chat",
|
indent <> highlight "/quit " <> " - quit chat",
|
||||||
"",
|
"",
|
||||||
"The commands may be abbreviated to a single letter: " <> listHighlight ["/c", "/f", "/g", "/p", "/h"] <> ", etc."
|
"The commands may be abbreviated to a single letter: " <> listHighlight ["/c", "/f", "/g", "/p", "/h"] <> ", etc."
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ module Simplex.Chat.View
|
|||||||
showMessageError,
|
showMessageError,
|
||||||
safeDecodeUtf8,
|
safeDecodeUtf8,
|
||||||
msgPlain,
|
msgPlain,
|
||||||
|
clientVersionInfo,
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
@@ -685,3 +686,6 @@ highlight' = highlight
|
|||||||
|
|
||||||
styleTime :: String -> StyledString
|
styleTime :: String -> StyledString
|
||||||
styleTime = Styled [SetColor Foreground Vivid Black]
|
styleTime = Styled [SetColor Foreground Vivid Black]
|
||||||
|
|
||||||
|
clientVersionInfo :: [StyledString]
|
||||||
|
clientVersionInfo = [plain $ "SimpleX Chat v" <> versionNumber]
|
||||||
Reference in new issue
Block a user