From c19a43f958cbfd6314bc9681b5e79afc6fc4a785 Mon Sep 17 00:00:00 2001 From: Blenkush Date: Fri, 16 Aug 2024 10:25:38 -0700 Subject: [PATCH] info chat command Chat command that displays platform and build in chat --- src/tui/CommandManager.cpp | 28 ++++++++++++++++++++++++++++ src/tui/CommandManager.h | 1 + 2 files changed, 29 insertions(+) diff --git a/src/tui/CommandManager.cpp b/src/tui/CommandManager.cpp index 886ac269..685b1eab 100644 --- a/src/tui/CommandManager.cpp +++ b/src/tui/CommandManager.cpp @@ -12,6 +12,7 @@ #include "Debug.h" // Debug::methods #include // std::random_device #include "Tags.h" +#include "GitVersion.h" CommandManager::CommandManager(CAvaraAppImpl *theApp) : itsApp(theApp) { @@ -106,6 +107,17 @@ CommandManager::CommandManager(CAvaraAppImpl *theApp) : itsApp(theApp) { "/dbg flag val <- sets debug flag to integer value", METHOD_TO_LAMBDA_VARGS(SetDebugFlag)); TextCommand::Register(cmd); + + cmd = new TextCommand("/info <- show build info", + [this](VectorOfArgs vargs) -> bool { + std::string infoString(GetOsName()); + infoString += " "; + itsApp->rosterWindow->SendRosterMessage(infoString); + itsApp->rosterWindow->SendRosterMessage(GIT_VERSION); + + return false; + }); + TextCommand::Register(cmd); } @@ -645,3 +657,19 @@ bool CommandManager::SetDebugFlag(VectorOfArgs vargs) { itsApp->AddMessageLine(os.str()); return true; } + +std::string CommandManager::GetOsName() { + #ifdef _WIN32 + return "Windows 32-bit"; + #elif _WIN64 + return "Windows 64-bit"; + #elif __APPLE__ || __MACH__ + return "Mac OSX"; + #elif __linux__ + return "Linux"; + #elif __unix || __unix__ + return "Unix"; + #else + return "Unknown OS"; + #endif +} diff --git a/src/tui/CommandManager.h b/src/tui/CommandManager.h index bbe918c3..e5fbf581 100644 --- a/src/tui/CommandManager.h +++ b/src/tui/CommandManager.h @@ -51,4 +51,5 @@ class CommandManager { // Coding helpers bool SetDebugFlag(VectorOfArgs); + std::string GetOsName(); };