2017-07-01 15:03:36 -04:00
|
|
|
package config
|
|
|
|
|
|
|
|
// Flags are applied after the configuration file is loaded.
|
|
|
|
// They are pointers to represent optional types, to tell whether they have been set.
|
|
|
|
type Flags struct {
|
2017-07-07 15:28:51 -04:00
|
|
|
Destination, Host *string
|
|
|
|
Drafts, Future, Unpublished *bool
|
|
|
|
Port *int
|
2017-07-01 15:03:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ApplyFlags overwrites the configuration with values from flags.
|
|
|
|
func (c *Config) ApplyFlags(flags Flags) {
|
|
|
|
if flags.Destination != nil {
|
|
|
|
c.Destination = *flags.Destination
|
|
|
|
}
|
2017-07-01 15:13:32 -04:00
|
|
|
if flags.Drafts != nil {
|
|
|
|
c.Drafts = *flags.Drafts
|
|
|
|
}
|
2017-07-01 15:03:36 -04:00
|
|
|
if flags.Future != nil {
|
|
|
|
c.Future = *flags.Future
|
|
|
|
}
|
2017-07-07 15:28:51 -04:00
|
|
|
if flags.Host != nil {
|
|
|
|
c.Host = *flags.Host
|
|
|
|
}
|
|
|
|
if flags.Port != nil {
|
|
|
|
c.Port = *flags.Port
|
|
|
|
}
|
2017-07-01 15:03:36 -04:00
|
|
|
if flags.Unpublished != nil {
|
|
|
|
c.Unpublished = *flags.Unpublished
|
|
|
|
}
|
|
|
|
}
|