cmdargshelp.cpp
1 //------------------------------------------------------------------------------
2 // cmdargshelp.cpp
3 //------------------------------------------------------------------------------
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301 USA
19 //
20 //------------------------------------------------------------------------------
21 // Copyright (C) 2015 "Zalewa" <zalewapl@gmail.com>
22 //------------------------------------------------------------------------------
23 #include "cmdargshelp.h"
24 
26 {
27 #ifdef Q_OS_WIN
28  const QString mountedWhere = tr("being assigned a different letter");
29  const QString dylibExtension = ".dll";
30 #else
31  const QString mountedWhere = tr("being mounted on a different path");
32  const QString dylibExtension = ".so";
33 #endif
34  QString help = "";
35  help += tr(
36  "--basedir <directory>\n"
37  " Changes the default storage directory to the specified\n"
38  " one (also in --portable mode). Doomseeker stores all of its\n"
39  " settings, cache and managed files in this directory.\n");
40  help += tr(
41  "--connect <protocol://ip[:port]>\n"
42  " Attempts to connect to the specified server.\n");
43  help += tr(
44  "--create-game\n"
45  " Launches Doomseeker in \"Create Game\" mode.\n");
46  help += tr(
47  "--datadir <directory>\n"
48  " Sets an explicit search location for\n"
49  " IP2C data along with plugins.\n"
50  " Can be specified multiple times.\n");
51  help += tr("--disable-plugin <plugin>\n"
52  " Ban a <plugin> from loading even if it is normally loaded.\n"
53  " Specify the plugin name without the 'lib' prefix or the file\n"
54  " extension, for ex. 'vavoom', not 'libvavoom%1'.\n"
55  ).arg(dylibExtension);
56  help += tr(
57  "--enable-plugin <plugin>\n"
58  " Load a <plugin> even if it is normally disabled/banned.\n"
59  " Specify the plugin name without the 'lib' prefix or the file\n"
60  " extension, for ex. 'vavoom', not 'libvavoom%1'.\n"
61  ).arg(dylibExtension);
62  help += tr(
63  "--help\n"
64  " Prints this list of command line arguments.\n");
65  help += tr(
66  "--rcon [plugin] [ip]\n"
67  " Launch the rcon client for the specified ip.\n");
68  help += tr(
69  "--portable\n"
70  " Starts the application in the portable mode:\n"
71  " - Doomseeker saves all the configuration files to the directory\n"
72  " where its executable resides. Normally, configuration is saved to\n"
73  " user's home directory. This directory can be changed with --basedir.\n"
74  " - The current working directory is forced to the directory where\n"
75  " Doomseeker's executable resides.\n"
76  " - Doomseeker will save in the configuration all paths as relative\n"
77  " in anticipation that the absolute paths may change between the runs,\n"
78  " for ex. due to the portable device %1.\n").arg(mountedWhere);
79  help += tr(
80  "--version-json [file|-]\n"
81  " Prints version info on Doomseeker and all\n"
82  " plugins in JSON format to specified file,\n"
83  " then closes the program. If file is not\n"
84  " specified or specified as '-', version info\n"
85  " is printed to stdout.\n");
86  help += tr(
87  "--verbose\n"
88  " Forces verbose logging to stderr.\n"
89  " This is the default in most cases.\n");
90  help += tr(
91  "--quiet\n"
92  " Forces no logging to stderr.\n"
93  " This is the default when dumping versions.\n");
94  return help;
95 }
96 
98 {
99  QString help = tr("Available command line parameters:\n");
100  help += argsHelp();
101  return help;
102 }
103 
104 QString CmdArgsHelp::missingArgs(int expectedArguments, QString option)
105 {
106  QString help = tr("doomseeker: expected %n argument(s) in option %1\n\n", nullptr, expectedArguments).arg(option);
107  help += availableCommands();
108  return help;
109 }
110 
111 QString CmdArgsHelp::unrecognizedOption(QString option)
112 {
113  QString help = tr("doomseeker: unrecognized option '%1'\n\n").arg(option);
114  help += availableCommands();
115  return help;
116 }