Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Improve default behaviour for @arg(minElements) #240

Open
tfenne opened this issue Jan 15, 2017 · 0 comments
Open

Improve default behaviour for @arg(minElements) #240

tfenne opened this issue Jan 15, 2017 · 0 comments

Comments

@tfenne
Copy link
Member

tfenne commented Jan 15, 2017

minElements currently defaults to one, so if you have a collection argument it requires at least a single value, and the only way to change this is to specify minElements=0.

I constantly do this and get tripped up:

@arg(doc="Optional thingies") val thingies: Seq[Thingy] = Nil

thinking that by assigning a default value to thingies I won't require any values on the command line.

I'd suggest that we make the following changes:

  1. Change the default value for minElements to a symbolic value, I'm going to use -1 for the examples.
  2. Change default behaviour so that if minElements == -1 and there is no default value supplied for an argument, interpret it as minElements == 1
  3. If there is a default value supplied (even if that default value is an empty collection) interpret minElements == -1 as minElements == 0.

I think this is more in keeping with the behaviour for non-collection args that are required unless there is a default value, and keeps backwards compatibility.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant