Changeset View
Changeset View
Standalone View
Standalone View
kate/main.cpp
Show First 20 Lines • Show All 177 Lines • ▼ Show 20 Line(s) | 85 | #endif | |||
---|---|---|---|---|---|
178 | 178 | | |||
179 | /** | 179 | /** | ||
180 | * Create command line parser and feed it with known options | 180 | * Create command line parser and feed it with known options | ||
181 | */ | 181 | */ | ||
182 | QCommandLineParser parser; | 182 | QCommandLineParser parser; | ||
183 | aboutData.setupCommandLine(&parser); | 183 | aboutData.setupCommandLine(&parser); | ||
184 | 184 | | |||
185 | // -s/--start session option | 185 | // -s/--start session option | ||
186 | const QCommandLineOption startSessionOption(QStringList() << QStringLiteral("s") << QStringLiteral("start"), i18n("Start Kate with a given session."), i18n("session")); | 186 | const QCommandLineOption startSessionOption( | ||
187 | QStringList({QStringLiteral("s"), QStringLiteral("start")}), | ||||
broulik: Just do `QStringList{QStringLiteral("s"), QStringLiteral("start")}` | |||||
tcanabrava: ok. | |||||
188 | i18n("Start Kate with a given session."), | ||||
189 | i18n("session")); | ||||
187 | parser.addOption(startSessionOption); | 190 | parser.addOption(startSessionOption); | ||
188 | 191 | | |||
189 | // --startanon session option | 192 | // --startanon session option | ||
190 | const QCommandLineOption startAnonymousSessionOption(QStringList() << QStringLiteral("startanon"), i18n("Start Kate with a new anonymous session, implies '-n'.")); | 193 | const QCommandLineOption startAnonymousSessionOption( | ||
194 | QStringList({QStringLiteral("startanon")}), | ||||
195 | i18n("Start Kate with a new anonymous session, implies '-n'.")); | ||||
191 | parser.addOption(startAnonymousSessionOption); | 196 | parser.addOption(startAnonymousSessionOption); | ||
192 | 197 | | |||
193 | // -n/--new option | 198 | // -n/--new option | ||
194 | const QCommandLineOption startNewInstanceOption(QStringList() << QStringLiteral("n") << QStringLiteral("new"), i18n("Force start of a new kate instance (is ignored if start is used and another kate instance already has the given session opened), forced if no parameters and no URLs are given at all.")); | 199 | const QCommandLineOption startNewInstanceOption( | ||
200 | QStringList({QStringLiteral("n"), QStringLiteral("new")}), | ||||
201 | i18n("Force start of a new kate instance (is ignored if start is used and another kate instance already has the given session opened), forced if no parameters and no URLs are given at all.") | ||||
202 | ); | ||||
195 | parser.addOption(startNewInstanceOption); | 203 | parser.addOption(startNewInstanceOption); | ||
196 | 204 | | |||
197 | // -b/--block option | 205 | // -b/--block option | ||
198 | const QCommandLineOption startBlockingOption(QStringList() << QStringLiteral("b") << QStringLiteral("block"), i18n("If using an already running kate instance, block until it exits, if URLs given to open.")); | 206 | const QCommandLineOption startBlockingOption( | ||
207 | QStringList({QStringLiteral("b"), QStringLiteral("block")}), | ||||
208 | i18n("If using an already running kate instance, block until it exits, if URLs given to open.")); | ||||
199 | parser.addOption(startBlockingOption); | 209 | parser.addOption(startBlockingOption); | ||
200 | 210 | | |||
201 | // -p/--pid option | 211 | // -p/--pid option | ||
202 | const QCommandLineOption usePidOption(QStringList() << QStringLiteral("p") << QStringLiteral("pid"), i18n("Only try to reuse kate instance with this pid (is ignored if start is used and another kate instance already has the given session opened)."), i18n("pid")); | 212 | const QCommandLineOption usePidOption( | ||
213 | QStringList({QStringLiteral("p"), QStringLiteral("pid")}), | ||||
214 | i18n("Only try to reuse kate instance with this pid (is ignored if start is used and another kate instance already has the given session opened)."), | ||||
215 | i18n("pid") | ||||
216 | ); | ||||
203 | parser.addOption(usePidOption); | 217 | parser.addOption(usePidOption); | ||
204 | 218 | | |||
205 | // -e/--encoding option | 219 | // -e/--encoding option | ||
206 | const QCommandLineOption useEncodingOption(QStringList() << QStringLiteral("e") << QStringLiteral("encoding"), i18n("Set encoding for the file to open."), i18n("encoding")); | 220 | const QCommandLineOption useEncodingOption( | ||
221 | QStringList({QStringLiteral("e"), QStringLiteral("encoding")}), | ||||
222 | i18n("Set encoding for the file to open."), | ||||
223 | i18n("encoding") | ||||
224 | ); | ||||
207 | parser.addOption(useEncodingOption); | 225 | parser.addOption(useEncodingOption); | ||
208 | 226 | | |||
209 | // -l/--line option | 227 | // -l/--line option | ||
210 | const QCommandLineOption gotoLineOption(QStringList() << QStringLiteral("l") << QStringLiteral("line"), i18n("Navigate to this line."), i18n("line")); | 228 | const QCommandLineOption gotoLineOption( | ||
229 | QStringList({QStringLiteral("l"), QStringLiteral("line")}), | ||||
230 | i18n("Navigate to this line."), | ||||
231 | i18n("line") | ||||
232 | ); | ||||
211 | parser.addOption(gotoLineOption); | 233 | parser.addOption(gotoLineOption); | ||
212 | 234 | | |||
213 | // -c/--column option | 235 | // -c/--column option | ||
214 | const QCommandLineOption gotoColumnOption(QStringList() << QStringLiteral("c") << QStringLiteral("column"), i18n("Navigate to this column."), i18n("column")); | 236 | const QCommandLineOption gotoColumnOption( | ||
237 | QStringList({QStringLiteral("c"), QStringLiteral("column")}), | ||||
238 | i18n("Navigate to this column."), | ||||
239 | i18n("column") | ||||
240 | ); | ||||
215 | parser.addOption(gotoColumnOption); | 241 | parser.addOption(gotoColumnOption); | ||
216 | 242 | | |||
217 | // -i/--stdin option | 243 | // -i/--stdin option | ||
218 | const QCommandLineOption readStdInOption(QStringList() << QStringLiteral("i") << QStringLiteral("stdin"), i18n("Read the contents of stdin.")); | 244 | const QCommandLineOption readStdInOption( | ||
245 | QStringList({QStringLiteral("i"), QStringLiteral("stdin")}), | ||||
246 | i18n("Read the contents of stdin.") | ||||
247 | ); | ||||
219 | parser.addOption(readStdInOption); | 248 | parser.addOption(readStdInOption); | ||
220 | 249 | | |||
221 | // --tempfile option | 250 | // --tempfile option | ||
222 | const QCommandLineOption tempfileOption(QStringList() << QStringLiteral("tempfile"), i18n("The files/URLs opened by the application will be deleted after use")); | 251 | const QCommandLineOption tempfileOption( | ||
252 | QStringList({QStringLiteral("tempfile")}), | ||||
apol: Why do you need to hardcode the QStringList constructor? | |||||
tcanabrava: i tried using only initializer list but got a compilation error. | |||||
I think because there's an overload for QString and QStringList and you can also do QString{"foo"} so it's ambiguous if you just use {} broulik: I think because there's an overload for `QString` and `QStringList` and you can also do… | |||||
253 | i18n("The files/URLs opened by the application will be deleted after use") | ||||
254 | ); | ||||
223 | parser.addOption(tempfileOption); | 255 | parser.addOption(tempfileOption); | ||
224 | 256 | | |||
225 | // urls to open | 257 | // urls to open | ||
226 | parser.addPositionalArgument(QStringLiteral("urls"), i18n("Documents to open."), i18n("[urls...]")); | 258 | parser.addPositionalArgument(QStringLiteral("urls"), i18n("Documents to open."), i18n("[urls...]")); | ||
227 | 259 | | |||
228 | /** | 260 | /** | ||
229 | * do the command line parsing | 261 | * do the command line parsing | ||
230 | */ | 262 | */ | ||
▲ Show 20 Lines • Show All 410 Lines • Show Last 20 Lines |
Just do QStringList{QStringLiteral("s"), QStringLiteral("start")}