iris/config/editor.go

46 lines
968 B
Go
Raw Normal View History

2016-05-30 16:08:09 +02:00
package config
import "github.com/imdario/mergo"
2016-06-03 04:11:50 +02:00
// Editor the configs for the Editor plugin
2016-05-30 16:08:09 +02:00
type Editor struct {
// Host if empty used the iris server's host
Host string
// Port if 0 4444
Port int
// WorkingDir if empty "./"
WorkingDir string
// Username if empty iris
Username string
// Password if empty admin!123
Password string
}
// DefaultEditor returns the default configs for the Editor plugin
func DefaultEditor() Editor {
return Editor{"", 4444, "." + pathSeparator, DefaultUsername, DefaultPassword}
}
// Merge merges the default with the given config and returns the result
func (c Editor) Merge(cfg []Editor) (config Editor) {
if len(cfg) > 0 {
config = cfg[0]
mergo.Merge(&config, c)
} else {
_default := c
config = _default
}
return
}
2016-06-03 04:11:50 +02:00
// MergeSingle merges the default with the given config and returns the result
2016-05-30 16:08:09 +02:00
func (c Editor) MergeSingle(cfg Editor) (config Editor) {
config = cfg
mergo.Merge(&config, c)
return
}