mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2026-08-14 15:33:36 -04:00
Several improvements related to packaging on Linux.
Added a manpages sub-project to generate man pages for wsjtx from AsciiDoc source. Add items required by Debian packaging and Free Desktop Standards. Add better command line processing to wsjtx including version and help options. Add a new command line option 'test-mode' that invokes the Qt test mode where all writable file locations are moved to a common directory. This is to allow application testing from a repeatable start point rather than have the test application sharing files with normal operations. See QStandardPaths::setTestModeEnabled() for details of the test location. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@4046 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
@@ -18,6 +18,9 @@
|
||||
#include <QSysInfo>
|
||||
#include <QDir>
|
||||
#include <QStandardPaths>
|
||||
#include <QCommandLineParser>
|
||||
#include <QCommandLineOption>
|
||||
#include <QStringList>
|
||||
|
||||
#include "revision_utils.hpp"
|
||||
|
||||
@@ -35,29 +38,50 @@ int main(int argc, char *argv[])
|
||||
try
|
||||
{
|
||||
setlocale (LC_NUMERIC, "C"); // ensure number forms are in
|
||||
// consistent format, do this after
|
||||
// instantiating QApplication so
|
||||
// that GUI has correct l18n
|
||||
|
||||
// consistent format, do this after
|
||||
// instantiating QApplication so
|
||||
// that GUI has correct l18n
|
||||
|
||||
// Override programs executable basename as application name.
|
||||
a.setApplicationName ("WSJT-X");
|
||||
a.setApplicationVersion (WSJTX_STRINGIZE (WSJTX_VERSION_MAJOR)
|
||||
"." WSJTX_STRINGIZE (WSJTX_VERSION_MINOR)
|
||||
"." WSJTX_STRINGIZE (WSJTX_VERSION_PATCH) " " + revision ());
|
||||
|
||||
QCommandLineParser parser;
|
||||
parser.setApplicationDescription ("\nJT65A & JT9 Weak Signal Communications Program.");
|
||||
parser.addHelpOption ();
|
||||
parser.addVersionOption ();
|
||||
|
||||
#if WSJT_STANDARD_FILE_LOCATIONS
|
||||
// support for multiple instances running from a single installation
|
||||
QCommandLineOption rig_option (QStringList {} << "r" << "rig-name"
|
||||
, a.translate ("main", "Where <rig-name> is for multi-instance support.")
|
||||
, a.translate ("main", "rig-name"));
|
||||
parser.addOption (rig_option);
|
||||
#endif
|
||||
|
||||
QCommandLineOption test_option (QStringList {} << "test-mode"
|
||||
, a.translate ("main", "Writable files in test location. Use with caution, for testing only."));
|
||||
parser.addOption (test_option);
|
||||
|
||||
parser.process (a);
|
||||
|
||||
QStandardPaths::setTestModeEnabled (parser.isSet (test_option));
|
||||
|
||||
bool multiple {false};
|
||||
|
||||
#if WSJT_STANDARD_FILE_LOCATIONS
|
||||
// support for multiple instances running from a single installation
|
||||
auto args = a.arguments ();
|
||||
auto rig_arg_index = args.lastIndexOf (QRegularExpression {R"((-r)|(--r(i?(g?))))"});
|
||||
if (rig_arg_index > 0 // not interested if somehow the exe is called -r or --rig
|
||||
&& rig_arg_index + 1 < args.size ())
|
||||
if (parser.isSet (rig_option))
|
||||
{
|
||||
auto temp_name = args.at (rig_arg_index + 1);
|
||||
if ('-' != temp_name[0]
|
||||
&& !temp_name.isEmpty ())
|
||||
auto temp_name = parser.value (rig_option);
|
||||
if (!temp_name.isEmpty ())
|
||||
{
|
||||
if (temp_name.contains (QRegularExpression {R"([\\/])"}))
|
||||
{
|
||||
throw std::runtime_error (QObject::tr ("Invalid rig name - \\ & / not allowed").toLocal8Bit ().data ());
|
||||
std::cerr << QObject::tr ("Invalid rig name - \\ & / not allowed").toLocal8Bit ().data () << std::endl;
|
||||
parser.showHelp (-1);
|
||||
}
|
||||
|
||||
a.setApplicationName (a.applicationName () + " - " + temp_name);
|
||||
|
||||
Reference in New Issue
Block a user