diff --git a/apps/simplex-chat/Main.hs b/apps/simplex-chat/Main.hs index e11f943171..cd7f353bba 100644 --- a/apps/simplex-chat/Main.hs +++ b/apps/simplex-chat/Main.hs @@ -6,6 +6,7 @@ module Main where import Simplex.Chat +import Simplex.Chat.Controller (versionNumber) import Simplex.Chat.Options import System.Directory (getAppUserDataDirectory) import System.Terminal (withTerminal) @@ -20,7 +21,7 @@ welcomeGetOpts :: IO ChatOpts welcomeGetOpts = do appDir <- getAppUserDataDirectory "simplex" 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 "type \"/help\" or \"/h\" for usage info" pure opts diff --git a/src/Simplex/Chat.hs b/src/Simplex/Chat.hs index 5427f7af97..cfd8b87a4c 100644 --- a/src/Simplex/Chat.hs +++ b/src/Simplex/Chat.hs @@ -89,6 +89,7 @@ data ChatCommand | UpdateProfile Profile | ShowProfile | QuitChat + | ShowVersion deriving (Show) defaultChatConfig :: ChatConfig @@ -317,6 +318,7 @@ processChatCommand user@User {userId, profile} = \case showUserProfileUpdated user user' ShowProfile -> showUserProfile profile QuitChat -> liftIO exitSuccess + ShowVersion -> printToView clientVersionInfo where contactMember :: Contact -> [GroupMember] -> Maybe GroupMember contactMember Contact {contactId} = @@ -1110,6 +1112,7 @@ chatCommandP = <|> ("/profile " <|> "/p ") *> (UpdateProfile <$> userProfile) <|> ("/profile" <|> "/p") $> ShowProfile <|> ("/quit" <|> "/q") $> QuitChat + <|> ("/version" <|> "/v") $> ShowVersion where displayName = safeDecodeUtf8 <$> (B.cons <$> A.satisfy refChar <*> A.takeTill (== ' ')) refChar c = c > ' ' && c /= '#' && c /= '@' diff --git a/src/Simplex/Chat/Controller.hs b/src/Simplex/Chat/Controller.hs index ae6dfd5e79..9fff4b0402 100644 --- a/src/Simplex/Chat/Controller.hs +++ b/src/Simplex/Chat/Controller.hs @@ -25,6 +25,9 @@ import Simplex.Messaging.Agent.Store.SQLite (SQLiteStore) import System.IO (Handle) import UnliftIO.STM +versionNumber :: String +versionNumber = "0.4.2" + data ChatConfig = ChatConfig { agentConfig :: AgentConfig, dbPoolSize :: Int, diff --git a/src/Simplex/Chat/Help.hs b/src/Simplex/Chat/Help.hs index 56f69a723e..8dd30ca0be 100644 --- a/src/Simplex/Chat/Help.hs +++ b/src/Simplex/Chat/Help.hs @@ -30,7 +30,7 @@ chatHelpInfo :: [StyledString] chatHelpInfo = map styleMarkdown - [ highlight "Using SimpleX chat prototype", + [ highlight "Using SimpleX Chat", "Follow these steps to set up a connection:", "", green "Step 1: " <> highlight "/connect" <> " - Alice adds a contact.", @@ -58,6 +58,7 @@ chatHelpInfo = indent <> highlight "/profile []" <> " - update user profile", indent <> highlight "/delete " <> " - delete contact and all messages with them", indent <> highlight "/markdown " <> " - show supported markdown syntax", + indent <> highlight "/version " <> " - show SimpleX Chat version", indent <> highlight "/quit " <> " - quit chat", "", "The commands may be abbreviated to a single letter: " <> listHighlight ["/c", "/f", "/g", "/p", "/h"] <> ", etc." diff --git a/src/Simplex/Chat/View.hs b/src/Simplex/Chat/View.hs index b2108eb791..b7f9510290 100644 --- a/src/Simplex/Chat/View.hs +++ b/src/Simplex/Chat/View.hs @@ -62,6 +62,7 @@ module Simplex.Chat.View showMessageError, safeDecodeUtf8, msgPlain, + clientVersionInfo, ) where @@ -685,3 +686,6 @@ highlight' = highlight styleTime :: String -> StyledString styleTime = Styled [SetColor Foreground Vivid Black] + +clientVersionInfo :: [StyledString] +clientVersionInfo = [plain $ "SimpleX Chat v" <> versionNumber]