@@ -19,29 +19,6 @@ class format_help_test : public sharg::test::test_fixture
19
19
bool flag_value{false };
20
20
std::vector<std::string> pos_opt_value{};
21
21
22
- static inline std::string basic_options_str = " Common options\n "
23
- " -h, --help\n "
24
- " Prints the help page.\n "
25
- " -hh, --advanced-help\n "
26
- " Prints the help page including advanced options.\n "
27
- " --version\n "
28
- " Prints the version information.\n "
29
- " --copyright\n "
30
- " Prints the copyright/license information.\n "
31
- " --export-help (std::string)\n "
32
- " Export the help page information. Value must be one of "
33
- #if SHARG_HAS_TDL
34
- " [html, man,\n ctd, cwl].\n " ;
35
- #else
36
- " [html, man].\n " ;
37
- #endif
38
-
39
- static inline std::string basic_version_str = " VERSION\n "
40
- " Last update:\n "
41
- " test_parser version:\n "
42
- " Sharg version: "
43
- + std::string{sharg::sharg_version_cstring} + " \n " ;
44
-
45
22
static inline std::string license_text = []()
46
23
{
47
24
std::ifstream license_file{std::string{SHARG_TEST_LICENSE_DIR} + " /LICENSE.md" };
@@ -120,7 +97,7 @@ TEST_F(format_help_test, quote_strings)
120
97
" Default: [\" Some\" , \" other\" , \" string\" ]\n "
121
98
" -e, --string5 (List of std::string)\n "
122
99
" Default: None\n\n "
123
- + basic_options_str + " \n " + basic_version_str ;
100
+ + basic_options_str + " \n " + version_str () ;
124
101
EXPECT_EQ (get_parse_cout_on_exit (parser), expected);
125
102
}
126
103
@@ -155,7 +132,7 @@ TEST_F(format_help_test, quote_paths)
155
132
" Default: [\" /some\" , \" /other\" , \" /path\" ]\n "
156
133
" -e, --path5 (List of std::filesystem::path)\n "
157
134
" Default: None\n\n "
158
- + basic_options_str + " \n " + basic_version_str ;
135
+ + basic_options_str + " \n " + version_str () ;
159
136
EXPECT_EQ (get_parse_cout_on_exit (parser), expected);
160
137
}
161
138
@@ -166,7 +143,7 @@ TEST_F(format_help_test, no_information)
166
143
expected = " test_parser\n "
167
144
" ===========\n "
168
145
" \n OPTIONS\n\n "
169
- + basic_options_str + " \n " + basic_version_str ;
146
+ + basic_options_str + " \n " + version_str () ;
170
147
EXPECT_EQ (get_parse_cout_on_exit (parser), expected);
171
148
}
172
149
@@ -179,7 +156,7 @@ TEST_F(format_help_test, with_short_copyright)
179
156
expected = " test_parser\n "
180
157
" ===========\n "
181
158
" \n OPTIONS\n\n "
182
- + basic_options_str + " \n " + basic_version_str + " \n "
159
+ + basic_options_str + " \n " + version_str () + " \n "
183
160
+ " LEGAL\n "
184
161
" test_parser Copyright: short\n "
185
162
" SeqAn Copyright: 2006-2024 Knut Reinert, FU-Berlin; released under the\n "
@@ -195,7 +172,7 @@ TEST_F(format_help_test, with_long_copyright)
195
172
expected = " test_parser\n "
196
173
" ===========\n "
197
174
" \n OPTIONS\n\n "
198
- + basic_options_str + " \n " + basic_version_str + " \n "
175
+ + basic_options_str + " \n " + version_str () + " \n "
199
176
+ " LEGAL\n "
200
177
" SeqAn Copyright: 2006-2024 Knut Reinert, FU-Berlin; released under the\n "
201
178
" 3-clause BSDL.\n "
@@ -211,7 +188,7 @@ TEST_F(format_help_test, with_citation)
211
188
expected = " test_parser\n "
212
189
" ===========\n "
213
190
" \n OPTIONS\n\n "
214
- + basic_options_str + " \n " + basic_version_str + " \n "
191
+ + basic_options_str + " \n " + version_str () + " \n "
215
192
+ " LEGAL\n "
216
193
" SeqAn Copyright: 2006-2024 Knut Reinert, FU-Berlin; released under the\n "
217
194
" 3-clause BSDL.\n "
@@ -227,7 +204,7 @@ TEST_F(format_help_test, with_author)
227
204
expected = " test_parser\n "
228
205
" ===========\n "
229
206
" \n OPTIONS\n\n "
230
- + basic_options_str + " \n " + basic_version_str + " \n "
207
+ + basic_options_str + " \n " + version_str () + " \n "
231
208
+ " LEGAL\n "
232
209
" Author: author\n "
233
210
" SeqAn Copyright: 2006-2024 Knut Reinert, FU-Berlin; released under the\n "
@@ -243,7 +220,7 @@ TEST_F(format_help_test, with_email)
243
220
expected = " test_parser\n "
244
221
" ===========\n "
245
222
" \n OPTIONS\n\n "
246
- + basic_options_str + " \n " + basic_version_str + " \n "
223
+ + basic_options_str + " \n " + version_str () + " \n "
247
224
+ " LEGAL\n "
248
225
" Contact: email\n "
249
226
" SeqAn Copyright: 2006-2024 Knut Reinert, FU-Berlin; released under the\n "
@@ -258,7 +235,7 @@ TEST_F(format_help_test, empty_advanced_help)
258
235
expected = " test_parser\n "
259
236
" ===========\n "
260
237
" \n OPTIONS\n\n "
261
- + basic_options_str + " \n " + basic_version_str ;
238
+ + basic_options_str + " \n " + version_str () ;
262
239
EXPECT_EQ (get_parse_cout_on_exit (parser), expected);
263
240
}
264
241
@@ -269,7 +246,7 @@ TEST_F(format_help_test, empty_version_call)
269
246
expected = " test_parser\n "
270
247
" ===========\n "
271
248
" \n "
272
- + basic_version_str ;
249
+ + version_str () ;
273
250
EXPECT_EQ (get_parse_cout_on_exit (parser), expected);
274
251
}
275
252
@@ -285,7 +262,7 @@ TEST_F(format_help_test, version_call)
285
262
expected = " test_parser\n "
286
263
" ===========\n "
287
264
" \n "
288
- + basic_version_str + " \n "
265
+ + version_str () + " \n "
289
266
+ " URL\n "
290
267
" https://seqan.de\n " ;
291
268
EXPECT_EQ (get_parse_cout_on_exit (parser), expected);
@@ -301,7 +278,7 @@ TEST_F(format_help_test, do_not_print_hidden_options)
301
278
expected = " test_parser\n "
302
279
" ===========\n "
303
280
" \n OPTIONS\n\n "
304
- + basic_options_str + " \n " + basic_version_str ;
281
+ + basic_options_str + " \n " + version_str () ;
305
282
EXPECT_EQ (get_parse_cout_on_exit (parser), expected);
306
283
}
307
284
@@ -359,7 +336,7 @@ TEST_F(format_help_test, advanced_options)
359
336
" list item.\n "
360
337
" some line.\n "
361
338
" \n "
362
- + basic_options_str + " \n " + basic_version_str ;
339
+ + basic_options_str + " \n " + version_str () ;
363
340
EXPECT_EQ (get_parse_cout_on_exit (parser), expected);
364
341
365
342
// with -hh everything is shown
@@ -392,7 +369,7 @@ TEST_F(format_help_test, advanced_options)
392
369
" list item.\n "
393
370
" some line.\n "
394
371
" \n "
395
- + basic_options_str + " \n " + basic_version_str ;
372
+ + basic_options_str + " \n " + version_str () ;
396
373
EXPECT_EQ (get_parse_cout_on_exit (parser), expected);
397
374
}
398
375
@@ -486,7 +463,7 @@ TEST_F(format_help_test, full_information)
486
463
" \n "
487
464
" example2\n "
488
465
" \n "
489
- + basic_version_str ;
466
+ + version_str () ;
490
467
EXPECT_EQ (get_parse_cout_on_exit (parser), expected);
491
468
}
492
469
@@ -540,10 +517,12 @@ TEST_F(format_help_test, copyright)
540
517
TEST_F (format_help_test, subcommand_parser)
541
518
{
542
519
bool flag_value{false };
520
+ int option_value{};
543
521
544
522
auto parser = get_subcommand_parser ({" -h" }, {" sub1" , " sub2" });
545
523
parser.info .description .push_back (" description" );
546
524
parser.add_flag (flag_value, sharg::config{.short_id = ' f' , .long_id = " foo" , .description = " A flag." });
525
+ parser.add_option (option_value, sharg::config{.short_id = ' o' , .long_id = " option" , .description = " An option." });
547
526
548
527
std::string expected = " test_parser\n "
549
528
" ===========\n "
@@ -561,11 +540,12 @@ TEST_F(format_help_test, subcommand_parser)
561
540
" The following options belong to the top-level parser and need to be\n "
562
541
" specified before the subcommand key word. Every argument after the\n "
563
542
" subcommand key word is passed on to the corresponding sub-parser.\n "
564
- " \n "
565
- " OPTIONS\n "
543
+ " \n OPTIONS\n "
566
544
" -f, --foo\n "
567
545
" A flag.\n "
546
+ " -o, --option (signed 32 bit integer)\n "
547
+ " An option. Default: 0\n "
568
548
" \n "
569
- + basic_options_str + " \n " + basic_version_str ;
549
+ + basic_options_str + " \n " + version_str () ;
570
550
EXPECT_EQ (get_parse_cout_on_exit (parser), expected);
571
551
}
0 commit comments