Implemented print long version

This commit is contained in:
Eism 2021-06-10 13:27:38 +02:00 committed by Igor Korsukov
parent 322262c8e2
commit dacf4cd961
4 changed files with 33 additions and 0 deletions

View file

@ -22,6 +22,8 @@
#include "commandlinecontroller.h"
#include "log.h"
#include "global/version.h"
#include "config.h"
using namespace mu::appshell;
using namespace mu::framework;
@ -34,6 +36,8 @@ void CommandLineController::parse(const QStringList& args)
m_parser.addPositionalArgument("scorefiles", "The files to open", "[scorefile...]");
m_parser.addOption(QCommandLineOption("long-version", "Print detailed version information"));
m_parser.addOption(QCommandLineOption({ "D", "monitor-resolution" }, "Specify monitor resolution", "DPI"));
// Converter mode
@ -61,6 +65,11 @@ void CommandLineController::apply()
// TODO: Open these files at launch if RunMode is Editor
QStringList scorefiles = m_parser.positionalArguments();
if (m_parser.isSet("long-version")) {
printLongVersion();
exit(EXIT_SUCCESS);
}
if (m_parser.isSet("D")) {
std::optional<float> val = floatValue("D");
if (val) {
@ -108,3 +117,14 @@ CommandLineController::ConverterTask CommandLineController::converterTask() cons
{
return m_converterTask;
}
void CommandLineController::printLongVersion() const
{
if (Version::unstable()) {
printf("MuseScore: Music Score Editor\nUnstable Prerelease for Version %s; Build %s\n",
Version::version().c_str(), Version::revision().c_str());
} else {
printf("MuseScore: Music Score Editor; Version %s; Build %s\n",
Version::version().c_str(), Version::revision().c_str());
}
}

View file

@ -54,6 +54,7 @@ public:
ConverterTask converterTask() const;
private:
void printLongVersion() const;
QCommandLineParser m_parser;
ConverterTask m_converterTask;

View file

@ -35,6 +35,11 @@ bool Version::unstable()
#endif
}
std::string Version::version()
{
return VERSION;
}
std::string Version::fullVersion()
{
std::string version(VERSION);
@ -45,3 +50,8 @@ std::string Version::fullVersion()
}
return version;
}
std::string Version::revision()
{
return MUSESCORE_REVISION;
}

View file

@ -31,7 +31,9 @@ class Version
public:
static bool unstable();
static std::string version();
static std::string fullVersion(); // e.g. 3.4.0-Beta
static std::string revision();
};
}
}