Merge lp:~chipaca/ubuntu-push/conflag-maybe into lp:ubuntu-push
Status: | Work in progress |
---|---|
Proposed branch: | lp:~chipaca/ubuntu-push/conflag-maybe |
Merge into: | lp:ubuntu-push |
Diff against target: |
110 lines (+40/-3) 2 files modified
config/config.go (+35/-3) config/config_test.go (+5/-0) |
To merge this branch: | bzr merge lp:~chipaca/ubuntu-push/conflag-maybe |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Samuele Pedroni | Needs Fixing | ||
Review via email: mp+203643@code.launchpad.net |
Description of the change
Toying with the idea of doing this.
With it, let's say you have a little program `conflag.go` that looked like
package main
import (
"flag"
"os"
"fmt"
"log"
)
type Config struct {
Stuff string `help:"Blah blah"`
}
func main() {
cfgF, err := os.Open(cfgFName)
if err != nil {
}
cfg := &Config{}
err = config.
if err != nil {
}
}
and a `config.json` that looked like
{ "stuff": "Yackity yack", "some_timeout": "2s" }
then
$ ./conflag -help
Usage of ./conflag:
-
-
$ ./conflag
&{Yackity yack 2s}
$ ./conflag -some_timeout=42m
&{Yackity yack 42m0s}
Unmerged revisions
- 29. By John Lenton
-
hmm... maybe.
I was thinking of trying something similar at some point
in this form is mostly missing tests,
and I wonder if allowing for supplying things with the command line means it's ok if they are left out from the config? or it the idea that the config should have defaults?
doing the former needs two passes over the values though,
should the functionality be opt-in?
btw flag supports TimeDuration flags, wondering if it means there's a way not to have to turn ConfigTimeDuration in a Value