fix: sort by server and type for app listing
This commit is contained in:
parent
8656ae947a
commit
5def18a9af
|
@ -59,7 +59,7 @@ var appListCommand = &cli.Command{
|
|||
logrus.Fatal(err)
|
||||
}
|
||||
apps, err := config.GetApps(appFiles)
|
||||
sort.Sort(config.ByServer(apps))
|
||||
sort.Sort(config.ByServerAndType(apps))
|
||||
tableCol := []string{"Server", "Type", "Name"}
|
||||
table := createTable(tableCol)
|
||||
table.SetAutoMergeCellsByColumnIndex([]int{0})
|
||||
|
|
|
@ -40,6 +40,18 @@ func (a ByServer) Less(i, j int) bool {
|
|||
return strings.ToLower(a[i].File.Server) < strings.ToLower(a[j].File.Server)
|
||||
}
|
||||
|
||||
type ByServerAndType []App
|
||||
|
||||
func (a ByServerAndType) Len() int { return len(a) }
|
||||
func (a ByServerAndType) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a ByServerAndType) Less(i, j int) bool {
|
||||
if a[i].File.Server == a[j].File.Server {
|
||||
return strings.ToLower(a[i].Type) < strings.ToLower(a[j].Type)
|
||||
} else {
|
||||
return strings.ToLower(a[i].File.Server) < strings.ToLower(a[j].File.Server)
|
||||
}
|
||||
}
|
||||
|
||||
type ByType []App
|
||||
|
||||
func (a ByType) Len() int { return len(a) }
|
||||
|
|
Loading…
Reference in New Issue