refactor global config into subpackage

This commit is contained in:
Bradley Cicenas
2017-02-07 03:33:09 +00:00
parent d5d00b730b
commit 85cd6864ba
6 changed files with 24 additions and 18 deletions

View File

@@ -2,6 +2,8 @@ package main
import (
"sort"
"github.com/bcicen/ctop/config"
)
type sortMethod func(c1, c2 *Container) bool
@@ -29,8 +31,8 @@ type Containers []*Container
func (a Containers) Len() int { return len(a) }
func (a Containers) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a Containers) Less(i, j int) bool {
f := Sorters[GlobalConfig["sortField"]]
if GlobalConfig["sortReversed"] == "1" {
f := Sorters[config.Global["sortField"]]
if config.Global["sortReversed"] == "1" {
return f(a[j], a[i])
}
return f(a[i], a[j])