kotlin-argparser icon indicating copy to clipboard operation
kotlin-argparser copied to clipboard

Don't be too strict with positional and positionalList names

Open holgerbrandl opened this issue 6 years ago • 0 comments

I'd expect the following bits to be legit but for some reason they are not:

class MyArgs(parser: ArgParser) {

    val imageDirectory by parser.positional("directory", "The directory which should be scanned for orphan images")

    val markdownFiles by parser.positionalList("<md files>", "Markdown files to be used as reference to detect orphans")
}
Exception in thread "main" java.lang.IllegalArgumentException: directory is not a valid argument name
	at com.xenomachina.argparser.PositionalDelegate.<init>(PositionalDelegate.kt:33)
	at com.xenomachina.argparser.ArgParser.positionalList(ArgParser.kt:315)
	at com.xenomachina.argparser.ArgParser.positional(ArgParser.kt:263)
	at com.xenomachina.argparser.ArgParser.positional(ArgParser.kt:246)
	at MyArgs.<init>(orphimg.kt:15)
	at OrphimgKt$main$args$1$1.invoke(orphimg.kt:20)
	at OrphimgKt$main$args$1$1.invoke(orphimg.kt)
	at com.xenomachina.argparser.ArgParser.parseInto(ArgParser.kt:469)

For some reason the PositionalDelegate is overly strict (just captialized letters) when it comes to naming my parameter.

holgerbrandl avatar Sep 20 '18 20:09 holgerbrandl