@@ -277,4 +277,74 @@ TEST_F(format_cwl_test, subparser)
277
277
" - index\n " ;
278
278
EXPECT_EQ (get_parse_cout_on_exit (sub_parser), expected_short);
279
279
}
280
+
281
+ TEST_F (format_cwl_test, subsubparser)
282
+ {
283
+ // Create variables for the arguments
284
+ int option_value{5 };
285
+ std::string option_value_string{};
286
+ std::filesystem::path option_value_path{};
287
+
288
+ // Create the dummy parser.
289
+ auto parser = get_subcommand_parser ({" index" , " show" , " --export-help" , " cwl" }, {" index" });
290
+
291
+ EXPECT_NO_THROW (parser.parse ());
292
+
293
+ auto & sub_parser = parser.get_sub_parser ();
294
+ ASSERT_EQ (sub_parser.info .app_name , " test_parser-index" );
295
+
296
+ sub_parser.add_subcommands ({" show" });
297
+ EXPECT_NO_THROW (sub_parser.parse ());
298
+
299
+ auto & sub_sub_parser = sub_parser.get_sub_parser ();
300
+ sub_sub_parser.add_option (option_value,
301
+ sharg::config{.short_id = ' j' ,
302
+ .long_id = " jint" ,
303
+ .description = " this is a required int option." ,
304
+ .required = true });
305
+ sub_sub_parser.add_option (option_value_string,
306
+ sharg::config{.short_id = ' s' ,
307
+ .long_id = " string" ,
308
+ .description = " this is a string option (advanced)." ,
309
+ .advanced = true ,
310
+ .required = false });
311
+ sub_sub_parser.add_option (option_value_path,
312
+ sharg::config{.short_id = ' \0 ' ,
313
+ .long_id = " path04" ,
314
+ .description = " a output file." ,
315
+ .validator = sharg::output_file_validator{}});
316
+
317
+ std::string expected_short =
318
+ " label: test_parser-index-show\n "
319
+ " doc: \"\"\n "
320
+ " inputs:\n "
321
+ " jint:\n "
322
+ " doc: this is a required int option.\n "
323
+ " type: long\n "
324
+ " inputBinding:\n "
325
+ " prefix: --jint\n "
326
+ " string:\n "
327
+ " doc: \" this is a string option (advanced). Default: \\\"\\\"\"\n "
328
+ " type: string?\n "
329
+ " inputBinding:\n "
330
+ " prefix: --string\n "
331
+ " path04:\n "
332
+ " doc: \" a output file. Default: \\\"\\\" . The output file must not exist already and write permissions "
333
+ " must be granted.\"\n "
334
+ " type: string?\n "
335
+ " inputBinding:\n "
336
+ " prefix: --path04\n "
337
+ " outputs:\n "
338
+ " path04:\n "
339
+ " type: File?\n "
340
+ " outputBinding:\n "
341
+ " glob: $(inputs.path04)\n "
342
+ " cwlVersion: v1.2\n "
343
+ " class: CommandLineTool\n "
344
+ " baseCommand:\n "
345
+ " - test_parser\n "
346
+ " - index\n "
347
+ " - show\n " ;
348
+ EXPECT_EQ (get_parse_cout_on_exit (sub_sub_parser), expected_short);
349
+ }
280
350
#endif
0 commit comments