From 1ed7d077a90019442f7dc078bc459058f63e4724 Mon Sep 17 00:00:00 2001 From: "Barak A. Pearlmutter" Date: Tue, 14 Jan 2020 15:11:31 +0000 Subject: [PATCH 1/4] git ignore app/moc_predefs.h --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ba2c815..a6f396d 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ *.pro.user.* *.moc moc_*.cpp +moc_*.h qrc_*.cpp ui_*.h Makefile* From 83684e8882d04978b3bc0b4894d3a7926d7d195e Mon Sep 17 00:00:00 2001 From: "Barak A. Pearlmutter" Date: Tue, 14 Jan 2020 16:37:22 +0000 Subject: [PATCH 2/4] squelch ugly quotes on 1st line of cool-retro-term --usage --- app/main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index 1bccbd0..ec56f1d 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -61,8 +61,7 @@ int main(int argc, char *argv[]) QStringList args = app.arguments(); if (args.contains("-h") || args.contains("--help")) { // BUG: This usage help text goes to stderr, should go to stdout. - // BUG: First line of output is surrounded by double quotes. - qDebug() << "Usage: " + args.at(0) + " [--default-settings] [--workdir ] [--program ] [-p|--profile ] [--fullscreen] [-h|--help]"; + qDebug().noquote() << "Usage: " + args.at(0) + " [--default-settings] [--workdir ] [--program ] [-p|--profile ] [--fullscreen] [-h|--help]"; qDebug() << " --default-settings Run cool-retro-term with the default settings"; qDebug() << " --workdir Change working directory to 'dir'"; qDebug() << " -e Command to execute. This option will catch all following arguments, so use it as the last option."; From b0e1962fa721663868a1fe936c5debfd0d383040 Mon Sep 17 00:00:00 2001 From: "Barak A. Pearlmutter" Date: Tue, 14 Jan 2020 16:43:27 +0000 Subject: [PATCH 3/4] send cool-retro-term --help and --version to stdout --- app/main.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index ec56f1d..ec8cd8e 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -60,23 +60,24 @@ 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")) { - // BUG: This usage help text goes to stderr, should go to stdout. - qDebug().noquote() << "Usage: " + args.at(0) + " [--default-settings] [--workdir ] [--program ] [-p|--profile ] [--fullscreen] [-h|--help]"; - qDebug() << " --default-settings Run cool-retro-term with the default settings"; - qDebug() << " --workdir Change working directory to 'dir'"; - qDebug() << " -e Command to execute. This option will catch all following arguments, so use it as the last option."; - qDebug() << " -T Set window title to 'title'."; - qDebug() << " --fullscreen Run cool-retro-term in fullscreen."; - qDebug() << " -p|--profile <prof> Run cool-retro-term with the given profile."; - qDebug() << " -h|--help Print this help."; - qDebug() << " --verbose Print additional information such as profiles and settings."; + 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")) { - qDebug() << ("cool-retro-term " + appVersion).toStdString().c_str(); + QTextStream cout(stdout, QIODevice::WriteOnly); + cout << "cool-retro-term " << appVersion << endl; return 0; } From 98ef7b329a97d709989d13c5a6b2da5d45df817f Mon Sep 17 00:00:00 2001 From: "Barak A. Pearlmutter" <barak+git@pearlmutter.net> Date: Thu, 16 Jan 2020 16:52:44 +0000 Subject: [PATCH 4/4] allow --help/-h/--version/-v options without graphics --- app/main.cpp | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index ec8cd8e..749a777 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -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;