felixge / godrone

GoDrone is a free software alternative firmware for the Parrot AR Drone 2.0.
http://www.godrone.io/
Other
205 stars 22 forks source link

Config file #21

Closed felixge closed 10 years ago

felixge commented 10 years ago

All drone settings should be configurable via a config file. Alternatively the same options should be settable via command line arguments or env variables. This will probably require some reflection based thingy.

As a config format I'm thinking yaml (there is a good Go implementation).

gwoo commented 10 years ago

Can you define the config parameters? I think toml or json would be better than yaml for a format. Json is native. I have used https://github.com/BurntSushi/toml with success. But I guess yaml could be supported too.

felixge commented 10 years ago

toml looks great! JSON sucks because it supports no comments (if you want to be compliant).

Anyway, I was thinking about creating a generic config pkg for go that takes a struct and fill it with values from any format (json,yaml,toml,env vars,cmd line args). The pkg should also allow serializing the same struct into any of these formats, and include the doc comments for the struct fields. This would simplify creating the default config file from values hardcoded in go.

gwoo commented 10 years ago

Yeah, I have a few such structs. I usually pass -conf or -c with the path to the file. By default it looks in the current directory for a config.toml. I can work on a pull request if this sounds good.

gwoo commented 10 years ago

Does https://github.com/felixge/godrone/blob/master/cmd/godrone/main.go#L18 cover it?

felixge commented 10 years ago

Does https://github.com/felixge/godrone/blob/master/cmd/godrone/main.go#L18 cover it?

Yeah, that's the main config struct / all we need. If you make a pull request that'd be awesome. Something simple would totally do for now, but eventually I want to be able to use the comments on the fields (which need to be written ; p) to write out a default config file that's easy for people to understand and modify.