@@ -214,11 +214,11 @@ class ArgParser(args: Array<out String>,
214214 * @param handler a function that computes the value of this option from an [OptionInvocation]
215215 */
216216 fun <T > option (
217- // TODO: fix ordering: help goes first
218217 // TODO: add optionalArg: Boolean
219218 vararg names : String ,
220- errorName : String ,
221219 help : String ,
220+ // TODO: make errorName nullable, and choose name from option names if null
221+ errorName : String ,
222222 argNames : List <String > = emptyList(),
223223 isRepeating : Boolean = false,
224224 handler : OptionInvocation <T >.() -> T
@@ -234,31 +234,6 @@ class ArgParser(args: Array<out String>,
234234 return delegate
235235 }
236236
237- /* *
238- * Creates a DelegateProvider for an option
239- * @param errorName name to use when talking about this option in error messages
240- * @param help the help text for this option
241- * @param argNames names of this option's arguments
242- * @param isRepeating whether or not it make sense to repeat this option -- usually used for options where
243- * specifying the option more than once yields a value than cannot be expressed by specifying the option only once
244- * @param handler a function that computes the value of this option from an [OptionInvocation]
245- */
246- fun <T > option (
247- // TODO: fix ordering: help goes first
248- // TODO: add optionalArg: Boolean
249- errorName : String ,
250- help : String ,
251- argNames : List <String > = emptyList(),
252- isRepeating : Boolean = false,
253- handler : OptionInvocation <T >.() -> T
254- ) = DelegateProvider { name ->
255- option(identifierToOptionName(name),
256- errorName = errorName,
257- help = help,
258- argNames = argNames,
259- isRepeating = isRepeating,
260- handler = handler) }
261-
262237 /* *
263238 * Creates a Delegate for a single positional argument which returns the argument's value.
264239 */
@@ -806,7 +781,6 @@ private const val ARG_INITIAL_CHAR_CLASS = "[A-Z]"
806781private const val ARG_CHAR_CLASS = " [A-Z0-9]"
807782private val ARG_NAME_RE = Regex (" ^$ARG_INITIAL_CHAR_CLASS +([-_]$ARG_CHAR_CLASS +)*$" )
808783
809-
810784fun <T > ArgParser.DelegateProvider<T>.default (newDefault : T ): ArgParser .DelegateProvider <T > {
811785 return ArgParser .DelegateProvider (ctor = ctor, defaultHolder = Holder (newDefault))
812786}
0 commit comments