allow --help/-h/--version/-v options without graphics

This commit is contained in:
Barak A. Pearlmutter 2020-01-16 16:52:44 +00:00
parent b0e1962fa7
commit 98ef7b329a

View File

@ -42,6 +42,28 @@ int main(int argc, char *argv[])
setenv("LC_CTYPE", "UTF-8", 1);
#endif
if (argc>1 && (!strcmp(argv[1],"-h") || !strcmp(argv[1],"--help"))) {
QTextStream cout(stdout, QIODevice::WriteOnly);
cout << "Usage: " << argv[0] << " [--default-settings] [--workdir <dir>] [--program <prog>] [-p|--profile <prof>] [--fullscreen] [-h|--help]" << endl;
cout << " --default-settings Run cool-retro-term with the default settings" << endl;
cout << " --workdir <dir> Change working directory to 'dir'" << endl;
cout << " -e <cmd> Command to execute. This option will catch all following arguments, so use it as the last option." << endl;
cout << " -T <title> Set window title to 'title'." << endl;
cout << " --fullscreen Run cool-retro-term in fullscreen." << endl;
cout << " -p|--profile <prof> Run cool-retro-term with the given profile." << endl;
cout << " -h|--help Print this help." << endl;
cout << " --verbose Print additional information such as profiles and settings." << endl;
return 0;
}
QString appVersion("1.1.1");
if (argc>1 && (!strcmp(argv[1],"-v") || !strcmp(argv[1],"--version"))) {
QTextStream cout(stdout, QIODevice::WriteOnly);
cout << "cool-retro-term " << appVersion << endl;
return 0;
}
QApplication app(argc, argv);
// set application attributes
// Has no effects, see https://bugreports.qt.io/browse/QTBUG-51293
@ -59,27 +81,6 @@ int main(int argc, char *argv[])
// Manage command line arguments from the cpp side
QStringList args = app.arguments();
if (args.contains("-h") || args.contains("--help")) {
QTextStream cout(stdout, QIODevice::WriteOnly);
cout << "Usage: " << args.at(0) << " [--default-settings] [--workdir <dir>] [--program <prog>] [-p|--profile <prof>] [--fullscreen] [-h|--help]" << endl;
cout << " --default-settings Run cool-retro-term with the default settings" << endl;
cout << " --workdir <dir> Change working directory to 'dir'" << endl;
cout << " -e <cmd> Command to execute. This option will catch all following arguments, so use it as the last option." << endl;
cout << " -T <title> Set window title to 'title'." << endl;
cout << " --fullscreen Run cool-retro-term in fullscreen." << endl;
cout << " -p|--profile <prof> Run cool-retro-term with the given profile." << endl;
cout << " -h|--help Print this help." << endl;
cout << " --verbose Print additional information such as profiles and settings." << endl;
return 0;
}
QString appVersion("1.1.1");
if (args.contains("-v") || args.contains("--version")) {
QTextStream cout(stdout, QIODevice::WriteOnly);
cout << "cool-retro-term " << appVersion << endl;
return 0;
}
// Manage default command
QStringList cmdList;