示例#1
0
文件: maindock.go 项目: sqp/godock
func getChangelog() string {
	changelogPath := globals.DirShareData(cdglobal.FileChangelog)
	msg := ""
	e := config.GetFromFile(log, changelogPath, func(cfg cdtype.ConfUpdater) {
		major, minor, micro := globals.VersionSplit()

		// Get first line
		strver := fmt.Sprintf("%d.%d.%d", major, minor, micro) // version without "alpha", "beta", "rc", etc.
		msg = cfg.Valuer("ChangeLog", strver).String()
		if msg == "" {
			log.Debug("changelog", "no info for version", globals.Version())
			return
		}
		msg = tran.Slate(msg)

		// Add all changelog lines for that version.
		i := 0
		for {
			strver := fmt.Sprintf("%d.%d.%d.%d", major, minor, micro, i)
			sub := cfg.Valuer("ChangeLog", strver).String()
			msg += "\n " + tran.Slate(sub)
			i++
		}
	})
	log.Err(e, "load changelog", changelogPath)
	return msg
}
示例#2
0
文件: confown.go 项目: sqp/godock
// Load loads the own config settings.
//
func (cs *ConfigSettings) Load() error {
	file := cs.File // Backup the file path.
	e := config.GetFromFile(cs.log, file, func(cfg cdtype.ConfUpdater) {
		// Special conf reflector around the config file parser.
		liste := cfg.UnmarshalGroup(cs, GuiGroup, config.GetBoth)
		for _, e := range liste {
			cs.log.Err(e, "confown parse")
		}
	})
	cs.File = file // Force value of file every time, it's set to blank by unmarshal.

	return e
}
示例#3
0
文件: uptoshare.go 项目: sqp/godock
func (up *Uploader) loadHistory() error {
	up.history = nil

	e := config.GetFromFile(up.Log, up.historyFile, func(cfg cdtype.ConfUpdater) {
		cfg.ParseGroups(func(group string, keys []cdtype.ConfKeyer) {
			links := NewLinks()
			up.history = append(up.history, links)
			for _, key := range keys {
				links.Add(key.Name(), key.String())
			}
		})
	})
	return up.Log.GetErr(e, "load uptoshare history")
}
示例#4
0
文件: maindock.go 项目: sqp/godock
// loadHidden will try to load the hidden config data from the file.
//
func loadHidden(path string) *hiddenConfig {
	file := filepath.Join(path, cdglobal.FileHiddenConfig)
	hidden := &hiddenConfig{}

	// Load data from file.
	e := config.GetFromFile(log, file, func(cfg cdtype.ConfUpdater) {
		cfg.UnmarshalGroup(hidden, hiddenGroup, config.GetTag)
	})

	if e != nil { // File missing, create it.
		conf := config.NewEmpty(log, file)

		conf.MarshalGroup(hidden, hiddenGroup, config.GetTag)
		conf.Set("Gui", "mode", "0") // another section unused here.

		e = conf.Save()
		log.Err(e, "create hidden conf", file)
	}

	return hidden
}