Easy to use and concise yet powerful and robust command line argument parsing for Kotlin
If the programName
passed to mainBody
is null, then the
system property com.xenomachina.argparser.programName
is used, if set.
The parseInto
method can be used as an inline alternative to force
.
Thanks @shanethehat!
Issue #24:
default
can now accept a lambda, making it possible to defer computation of
defaults until actually required.
Thanks @shanethehat!
All instances of progName
have been renamed to programName
.
The gradle wrapper has been updated. Thanks @ColinHebert!
Issue #14 — previously, automatic option naming would turn "camelCase" into "--camelCase". Now it is converted to "--camel-case".
Likewise, positinal argument auto-naming used to convert "camelCase" into "CAMELCASE". Now it is converted to "CAMEL-CASE".
Improve help formatting w/long program names
README formatting improved. Thanks @konfilios!
ArgParser.option
is now a public method, so it's possible to create many
new option types that were not previously possible. The existing option types
are all written in terms of option
, so they can be used to get an idea of
how it works.
More tests have been added.
Started using keepachangelog.com format for CHANGELOG.md
Made minor improvements to release process
The storing
, adding
and positionalList
methods of ArgParser
have had
their parameters slightly reordered to be consistent with the other methods.
This is an incompatible change. The name(s) come first, if any, followed by
help
. Other parameters appear after help
, with the transform
function,
if any, last. It is recommended that clients either pass the transform as a
block (ie: with braces) or as a named parameter, as any future new parameters
will necessarily change its position in the list.
Delegate and DelegateProvider are now abstract classes with internal
constructors. This makes it much easier for me to separate internal and
public parts of their API. This is an incompatible change, however it
shouldn't really affect you unless you were trying to implement Delegate
,
which was't supported to begin with.
default
methods on both Delegate
and DelegateProvider
are now extension
methods. This makes it possible to generalize the type when adding a
default. This is most noticable when using a nullable value (or null
itself) for the default, though may also be useful in other cases (eg: a
"storing" that always produces a Rectangle
, but you want the default to be
a Circle
. The resulting delegate will be a Delegate<Shape>
.)
Registration of delegates now takes place at binding-time rather than construction time. This should be pretty indistinguishable from the old behavior unless you're creating delegates without binding them.
Help formatting has been improved so that it's far less likely to wrap option names in the usage table.
There have been numerous bugfixes, particularly around positionals
Each of the ArgParser methods that takes names and returns a Delegate<T> has an overload that takes no name, but returns a DelegateProvider<T>.
A DelegateProvider<T> has an operator fun provideDelegate
that returns a
Delegate<T>, using a name derived from the name of the property the
DelegateProvider is being bound to.
addValidtator
is now deprecated. Use addValidator
instead.Removed documentation of option
from README.md
, as it is internal
Corrected spelling of addValidator
. addValidtator
is still there, but
deprecated. It'll probably be removed in the next release, barring the
addition of potato functionality.