1919package com.xenomachina.argparser.tests
2020
2121import com.xenomachina.argparser.ArgParser
22- import com.xenomachina.argparser.ArgParser.DelegateProvider.Companion.identifierToArgName
2322import com.xenomachina.argparser.ArgParser.DelegateProvider.Companion.identifierToOptionName
2423import com.xenomachina.argparser.DefaultHelpFormatter
2524import com.xenomachina.argparser.HelpFormatter
@@ -80,49 +79,49 @@ class OptionNameValidationTest : Test({
8079 val parser = parserOf()
8180
8281 // These are all acceptable.
83- parser.option<Int >("-x", errorName = "", help = TEST_HELP ) { 0 }
84- parser.option<Int >("--x", errorName = "", help = TEST_HELP ) { 0 }
85- parser.option<Int >("--xy", errorName = "", help = TEST_HELP ) { 0 }
86- parser.option<Int >("-X ", errorName = "", help = TEST_HELP ) { 0 }
87- parser.option<Int >("--X ", errorName = "", help = TEST_HELP ) { 0 }
88- parser.option<Int >("--XY ", errorName = "", help = TEST_HELP ) { 0 }
89- parser.option<Int >("--X -Y ", errorName = "", help = TEST_HELP ) { 0 }
90- parser.option<Int >("--X_Y ", errorName = "", help = TEST_HELP ) { 0 }
91- parser.option<Int >("-5", errorName = "", help = TEST_HELP ) { 0 }
92- parser.option<Int >("--5", errorName = "", help = TEST_HELP ) { 0 }
93- parser.option<Int >("--5Y", errorName = "", help = TEST_HELP ) { 0 }
94- parser.option<Int >("--X5 ", errorName = "", help = TEST_HELP ) { 0 }
82+ parser.option<Int >("-x", help = TEST_HELP ) { 0 }
83+ parser.option<Int >("--x", help = TEST_HELP ) { 0 }
84+ parser.option<Int >("--xy", help = TEST_HELP ) { 0 }
85+ parser.option<Int >("-X ", help = TEST_HELP ) { 0 }
86+ parser.option<Int >("--X ", help = TEST_HELP ) { 0 }
87+ parser.option<Int >("--XY ", help = TEST_HELP ) { 0 }
88+ parser.option<Int >("--X -Y ", help = TEST_HELP ) { 0 }
89+ parser.option<Int >("--X_Y ", help = TEST_HELP ) { 0 }
90+ parser.option<Int >("-5", help = TEST_HELP ) { 0 }
91+ parser.option<Int >("--5", help = TEST_HELP ) { 0 }
92+ parser.option<Int >("--5Y", help = TEST_HELP ) { 0 }
93+ parser.option<Int >("--X5 ", help = TEST_HELP ) { 0 }
9594
9695 shouldThrow<IllegalArgumentException > {
97- parser.option<Int >("-_ ", errorName = "", help = TEST_HELP ) { 0 }
96+ parser.option<Int >("-_ ", help = TEST_HELP ) { 0 }
9897 }
9998
10099 shouldThrow<IllegalArgumentException > {
101- parser.option<Int >("---x", errorName = "", help = TEST_HELP ) { 0 }
100+ parser.option<Int >("---x", help = TEST_HELP ) { 0 }
102101 }
103102
104103 shouldThrow<IllegalArgumentException > {
105- parser.option<Int >("x", errorName = "", help = TEST_HELP ) { 0 }
104+ parser.option<Int >("x", help = TEST_HELP ) { 0 }
106105 }
107106
108107 shouldThrow<IllegalArgumentException > {
109- parser.option<Int >("", errorName = "", help = TEST_HELP ) { 0 }
108+ parser.option<Int >("", help = TEST_HELP ) { 0 }
110109 }
111110
112111 shouldThrow<IllegalArgumentException > {
113- parser.option<Int >("-xx", errorName = "", help = TEST_HELP ) { 0 }
112+ parser.option<Int >("-xx", help = TEST_HELP ) { 0 }
114113 }
115114
116115 shouldThrow<IllegalArgumentException > {
117- parser.option<Int >("--foo bar", errorName = "", help = TEST_HELP ) { 0 }
116+ parser.option<Int >("--foo bar", help = TEST_HELP ) { 0 }
118117 }
119118
120119 shouldThrow<IllegalArgumentException > {
121- parser.option<Int >("--foo--bar", errorName = "", help = TEST_HELP ) { 0 }
120+ parser.option<Int >("--foo--bar", help = TEST_HELP ) { 0 }
122121 }
123122
124123 shouldThrow<IllegalArgumentException > {
125- parser.option<Int >("--f!oobar", errorName = "", help = TEST_HELP ) { 0 }
124+ parser.option<Int >("--f!oobar", help = TEST_HELP ) { 0 }
126125 }
127126})
128127
@@ -172,18 +171,17 @@ class PositionalNameValidationTest : Test({
172171 }
173172
174173 // This should be acceptable
175- parser.option<Int >("--foobar", argNames = listOf("X -Y "), errorName = "", help = TEST_HELP ) { 0 }
174+ parser.option<Int >("--foobar", argNames = listOf("X -Y "), help = TEST_HELP ) { 0 }
176175
177176 // This should not
178177 shouldThrow<IllegalArgumentException > {
179- parser.option<Int >("--foobar", argNames = listOf("X --Y "), errorName = "", help = TEST_HELP ) { 0 }
178+ parser.option<Int >("--foobar", argNames = listOf("X --Y "), help = TEST_HELP ) { 0 }
180179 }
181180})
182181
183182class ArglessShortOptionsTest : Test ({
184183 class Args (parser: ArgParser ) {
185184 val xyz by parser.option<MutableList <String >>("-x", "-y", "-z",
186- errorName = "VALUE_NAME ",
187185 help = TEST_HELP ) {
188186 value.orElse { mutableListOf<String >() }.apply {
189187 add("$optionName")
@@ -202,7 +200,6 @@ class ShortOptionsWithArgsTest : Test({
202200 val b by parser.flagging("-b", help = TEST_HELP )
203201 val c by parser.flagging("-c", help = TEST_HELP )
204202 val xyz by parser.option<MutableList <String >>("-x", "-y", "-z",
205- errorName = "VALUE_NAME ",
206203 argNames = oneArgName, help = TEST_HELP ) {
207204 value.orElse { mutableListOf<String >() }.apply {
208205 add("$optionName:${arguments.first()}")
@@ -236,14 +233,12 @@ class ShortOptionsWithArgsTest : Test({
236233class MixedShortOptionsTest : Test ({
237234 class Args (parser: ArgParser ) {
238235 val def by parser.option<MutableList <String >>("-d", "-e", "-f",
239- errorName = "VALUE_NAME ",
240236 help = TEST_HELP ) {
241237 value.orElse { mutableListOf<String >() }.apply {
242238 add("$optionName")
243239 }
244240 }
245241 val abc by parser.option<MutableList <String >>("-a", "-b", "-c",
246- errorName = "VALUE_NAME ",
247242 help = TEST_HELP ) {
248243 value.orElse { mutableListOf<String >() }.apply {
249244 add("$optionName")
@@ -260,21 +255,18 @@ class MixedShortOptionsTest : Test({
260255class MixedShortOptionsWithArgsTest : Test ({
261256 class Args (parser: ArgParser ) {
262257 val def by parser.option<MutableList <String >>("-d", "-e", "-f",
263- errorName = "VALUE_NAME ",
264258 help = TEST_HELP ) {
265259 value.orElse { mutableListOf<String >() }.apply {
266260 add("$optionName")
267261 }
268262 }
269263 val abc by parser.option<MutableList <String >>("-a", "-b", "-c",
270- errorName = "VALUE_NAME ",
271264 help = TEST_HELP ) {
272265 value.orElse { mutableListOf<String >() }.apply {
273266 add("$optionName")
274267 }
275268 }
276269 val xyz by parser.option<MutableList <String >>("-x", "-y", "-z",
277- errorName = "VALUE_NAME ",
278270 argNames = oneArgName,
279271 help = TEST_HELP ) {
280272 value.orElse { mutableListOf<String >() }.apply {
@@ -293,7 +285,6 @@ class MixedShortOptionsWithArgsTest : Test({
293285class ArglessLongOptionsTest : Test ({
294286 class Args (parser: ArgParser ) {
295287 val xyz by parser.option<MutableList <String >>("--xray", "--yellow", "--zebra",
296- errorName = "XYZ ",
297288 help = TEST_HELP ) {
298289 value.orElse { mutableListOf<String >() }.apply {
299290 add("$optionName")
@@ -309,7 +300,6 @@ class ArglessLongOptionsTest : Test({
309300class LongOptionsWithOneArgTest : Test ({
310301 class Args (parser: ArgParser ) {
311302 val xyz by parser.option<MutableList <String >>("--xray", "--yellow", "--zaphod",
312- errorName = "XYZ ",
313303 argNames = oneArgName,
314304 help = TEST_HELP ) {
315305 value.orElse { mutableListOf<String >() }.apply {
@@ -334,7 +324,6 @@ class LongOptionsWithOneArgTest : Test({
334324class LongOptionsWithMultipleArgsTest : Test ({
335325 class Args (parser: ArgParser ) {
336326 val xyz by parser.option<MutableList <String >>("--xray", "--yak", "--zaphod",
337- errorName = "XYZ ",
338327 argNames = listOf("COLOR ", "SIZE ", "FLAVOR "),
339328 help = TEST_HELP ) {
340329 value.orElse { mutableListOf<String >() }.apply { add("$optionName:${arguments}") }
@@ -375,7 +364,6 @@ class DelegateProviderTest : Test({
375364 fun ArgParser .putting(help: String ): ArgParser .DelegateProvider <Map <String , String >> =
376365 ArgParser .DelegateProvider { identifier ->
377366 option<MutableMap <String , String >>(identifierToOptionName(identifier),
378- errorName = identifierToArgName(identifier),
379367 argNames = listOf("KEY ", "VALUE "),
380368 help = help) {
381369 value.orElse { mutableMapOf<String , String >() }.apply { put(arguments.first(), arguments.last()) }
@@ -1296,7 +1284,6 @@ class AutoNamedLongOptionWithMultipleArgsTest : Test({
12961284 class Args (parser: ArgParser ) {
12971285 val xyz by parser.option<MutableList <String >>(
12981286 "--xyz",
1299- errorName = "XYZ ",
13001287 argNames = listOf("COLOR ", "SIZE ", "FLAVOR "),
13011288 help = TEST_HELP ) {
13021289 value.orElse { mutableListOf<String >() }.apply { add("$optionName:${arguments}")
0 commit comments