Skip to content

Commit 21367c3

Browse files
committed
[FIX] CWL: positional options are required
positional list options are optional
1 parent 38fdba5 commit 21367c3

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

include/sharg/detail/format_tdl.hpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,14 @@ class format_tdl : format_base
298298
++positional_option_count;
299299
auto description = config.description + default_message + validator_message;
300300

301-
parameters.push_back(tdl::Node{
302-
.name = id,
303-
.description = description,
304-
.tags = {},
305-
.value = tdl::StringValue{},
306-
});
301+
parameters.push_back(tdl::Node{.name = id,
302+
.description = description,
303+
.tags = {detail::is_container_option<option_type> ? "" : "required"}});
304+
305+
if constexpr (detail::is_container_option<option_type>)
306+
parameters.back().value = tdl::StringValueList{};
307+
else
308+
parameters.back().value = tdl::StringValue{};
307309
});
308310
}
309311

test/unit/detail/format_cwl_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ TEST(format_cwl_test, full_information)
8585
"inputs:\n"
8686
" positional_0:\n"
8787
" doc: this is a positional option.\n"
88-
" type: string?\n"
88+
" type: string\n"
8989
" positional_1:\n"
9090
" doc: \"this is a positional option. Default: []\"\n"
91-
" type: string?\n"
91+
" type: string[]?\n"
9292
" int:\n"
9393
" doc: \"this is a int option. Default: 5\"\n"
9494
" type: long?\n"
@@ -215,10 +215,10 @@ TEST(format_cwl_test, subparser)
215215
"inputs:\n"
216216
" positional_0:\n"
217217
" doc: this is a positional option.\n"
218-
" type: string?\n"
218+
" type: string\n"
219219
" positional_1:\n"
220220
" doc: \"this is a positional option. Default: []\"\n"
221-
" type: string?\n"
221+
" type: string[]?\n"
222222
" int:\n"
223223
" doc: \"this is a int option. Default: 5\"\n"
224224
" type: long?\n"

0 commit comments

Comments
 (0)