jessevdk/go-flags — pull request #67 by zimmski (2014-03-24 12:36:43+00:00)
Title: Fix overwriting defaults

Default values of array or map options are never overwritten. Instead they are combined with CLI (and config) values. This is not the usual behavior of programs where different argument layers can overwrite each other.

e.g.

```go
type Op struct {
Verbose []bool `short:"v" default:"true"`
}
```

Called with arguments

```bash
program -v -v
```

would result in three instead of two verbose levels. With this pull request the example would result in the expected two verbose levels. This fixes also one of the problems of #42 and #54 and I must say that I am not completely happy with the overall handling of this and values in general. I therefore like to propose a change in handling values internally which would also address #42 and #54. (If I should add an issue to further discuss this, please say so) Instead of having option.value and option.defaultValue I would propose having only option.value as a slice. New layers of arguments are then simply appended to this slice.

E.g. the above example would result in this internal option.value
```go
[][]bool{
[]bool{true},
[]bool{true, true},
}
```
The default value of an option always has index 0 and the last element in the slice is the concluding value of an option. This would make implementing overwriting argument layers like
defaults -> config(s) -> environment variables -> CLI arguments
much easier as it comes naturally with the internal design, without giving up on option validation.