feat: add --version option to deskflow-core
This commit is contained in:
parent
d3c0ce8895
commit
e2b4bc45bd
1 changed files with 22 additions and 0 deletions
|
|
@ -6,6 +6,7 @@
|
||||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "VersionInfo.h"
|
||||||
#include "arch/Arch.h"
|
#include "arch/Arch.h"
|
||||||
#include "base/EventQueue.h"
|
#include "base/EventQueue.h"
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
|
|
@ -21,6 +22,8 @@
|
||||||
#include <QSharedMemory>
|
#include <QSharedMemory>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
const static auto kHeader = QStringLiteral("%1-core: %2\n").arg(kAppId, kDisplayVersion);
|
||||||
|
|
||||||
void showHelp()
|
void showHelp()
|
||||||
{
|
{
|
||||||
std::cout << "Usage: deskflow-core <server | client> [...options]" << std::endl;
|
std::cout << "Usage: deskflow-core <server | client> [...options]" << std::endl;
|
||||||
|
|
@ -43,6 +46,20 @@ bool isHelp(int argc, char **argv)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void showVersion()
|
||||||
|
{
|
||||||
|
std::cout << qPrintable(kHeader) << qPrintable(kCopyright) << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isVersion(int argc, char **argv)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < argc; ++i) {
|
||||||
|
if (argv[i] == std::string("--version") || argv[i] == std::string("-v"))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool isServer(int argc, char **argv)
|
bool isServer(int argc, char **argv)
|
||||||
{
|
{
|
||||||
return (argc > 1 && argv[1] == std::string("server"));
|
return (argc > 1 && argv[1] == std::string("server"));
|
||||||
|
|
@ -65,6 +82,11 @@ int main(int argc, char **argv)
|
||||||
return s_exitSuccess;
|
return s_exitSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isVersion(argc, argv)) {
|
||||||
|
showVersion();
|
||||||
|
return s_exitSuccess;
|
||||||
|
}
|
||||||
|
|
||||||
// Create a shared memory segment with a unique key
|
// Create a shared memory segment with a unique key
|
||||||
// This is to prevent a new instance from running if one is already running
|
// This is to prevent a new instance from running if one is already running
|
||||||
QSharedMemory sharedMemory("deskflow-core");
|
QSharedMemory sharedMemory("deskflow-core");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue