From 576e979df4a54df9bf5ffeae3559f488b3045268 Mon Sep 17 00:00:00 2001 From: Orochimarufan Date: Thu, 21 Feb 2013 19:35:52 +0100 Subject: Implement About Dialog Prepared XDG icon theme in :/icons/multimc. will only be usefull as soon as Qt decides to support custom fallback themes. use the resources directly for now. --- main.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index efabc20a..fb7a5061 100644 --- a/main.cpp +++ b/main.cpp @@ -27,6 +27,8 @@ #include "util/cmdutils.h" +#include "config.h" + using namespace Util::Commandline; int main(int argc, char *argv[]) @@ -46,7 +48,11 @@ int main(int argc, char *argv[]) // --help parser.addSwitch("help"); parser.addShortOpt("help", 'h'); - parser.addDocumentation("help", "displays help on command line parameters"); + parser.addDocumentation("help", "display this help and exit."); + // --version + parser.addSwitch("version"); + parser.addShortOpt("version", 'V'); + parser.addDocumentation("version", "display program version and exit."); // --dir parser.addOption("dir", app.applicationDirPath()); parser.addShortOpt("dir", 'd'); @@ -70,6 +76,7 @@ int main(int argc, char *argv[]) args = parser.parse(app.arguments()); } catch(ParsingError e) { std::cerr << "CommandLineError: " << e.what() << std::endl; + std::cerr << "Try '%1 -h' to get help on MultiMC's command line parameters." << std::endl; return 1; } @@ -79,16 +86,24 @@ int main(int argc, char *argv[]) return 0; } + // display version and exit + if (args["version"].toBool()) { + std::cout << VERSION_STR << " " << JENKINS_BUILD_TAG << " " << (ARCH==x64?"x86_64":"x86") << std::endl; + return 0; + } + // update // Note: cwd is always the current executable path! if (!args["update"].isNull()) { std::cout << "Performing MultiMC update: " << qPrintable(args["update"].toString()) << std::endl; + QString cwd = QDir::currentPath(); QDir::setCurrent(app.applicationDirPath()); QFile file(app.applicationFilePath()); file.copy(args["update"].toString()); if(args["quietupdate"].toBool()) return 0; + QDir::setCurrent(cwd); } // change directory -- cgit v1.2.3