Auto-propulate Go structs into command-line flags.
Allows these:
type ChipotleOrder struct {
Rice string
Beans string
FajitaVegetables boolean
Meat string
Salsa []string
Corn boolean
SourCream boolean
Cheese boolean
Guacamole boolean
}
type PlacedOrder struct {
ChipotleOrder
Address
TimeReady time.Time
}
...to accept these:
$ ./main -placed-order \
-rice brown \
-beans pinto \
-fajita-vegetables \
-meat barbacoa \
-salsa mild,hot \
-guacamole \
-time-ready 7:56PM \
-address 'last used'
...without you having to write all those flags yourself.
For a Go playground example of the required reflection to do this magic, go here: http://play.golang.org/p/4bTL5v7OSi