Rename QEntrySortConfig to QSortConfig
This commit is contained in:
parent
187164fc7d
commit
6749bdbb96
|
@ -6,7 +6,7 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
)
|
)
|
||||||
|
|
||||||
type QEntrySortConfig struct {
|
type QSortConfig struct {
|
||||||
attributes []qEntryAttributeSortConfig
|
attributes []qEntryAttributeSortConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@ type qEntryAttributeSortConfig struct {
|
||||||
order string
|
order string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSortConfig() QEntrySortConfig {
|
func NewSortConfig() QSortConfig {
|
||||||
return QEntrySortConfig{}
|
return QSortConfig{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func isQEntryAttribute(attributeName string) bool {
|
func isQEntryAttribute(attributeName string) bool {
|
||||||
|
@ -30,7 +30,7 @@ func isQEntryAttribute(attributeName string) bool {
|
||||||
return isValidAttribute
|
return isValidAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c QEntrySortConfig) By(attributeName string, order string) (QEntrySortConfig, error) {
|
func (c QSortConfig) By(attributeName string, order string) (QSortConfig, error) {
|
||||||
if !isQEntryAttribute(attributeName) {
|
if !isQEntryAttribute(attributeName) {
|
||||||
return c, errors.New(fmt.Sprintf("Invalid sort attribute: '%s' given!", attributeName))
|
return c, errors.New(fmt.Sprintf("Invalid sort attribute: '%s' given!", attributeName))
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ func (c QEntrySortConfig) By(attributeName string, order string) (QEntrySortConf
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (queue MailQ) Sort(config QEntrySortConfig) {
|
func (queue MailQ) Sort(config QSortConfig) {
|
||||||
if len(config.attributes) == 0 {
|
if len(config.attributes) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
4
main.go
4
main.go
|
@ -39,7 +39,7 @@ func parseArguments() {
|
||||||
settings["usePager"] = strconv.FormatBool(*usePagerPtr)
|
settings["usePager"] = strconv.FormatBool(*usePagerPtr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultSortConfig() mailq.QEntrySortConfig {
|
func defaultSortConfig() mailq.QSortConfig {
|
||||||
sortConfig := mailq.NewSortConfig()
|
sortConfig := mailq.NewSortConfig()
|
||||||
sortConfig, _ = sortConfig.By("Status", "ASC")
|
sortConfig, _ = sortConfig.By("Status", "ASC")
|
||||||
sortConfig, _ = sortConfig.By("Sender", "ASC")
|
sortConfig, _ = sortConfig.By("Sender", "ASC")
|
||||||
|
@ -47,7 +47,7 @@ func defaultSortConfig() mailq.QEntrySortConfig {
|
||||||
return sortConfig
|
return sortConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func showQueue(sortConfig mailq.QEntrySortConfig) {
|
func showQueue(sortConfig mailq.QSortConfig) {
|
||||||
queue, err := fetchQueue()
|
queue, err := fetchQueue()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Could not fetch queue entries: %s\n", err.Error())
|
fmt.Printf("Could not fetch queue entries: %s\n", err.Error())
|
||||||
|
|
Loading…
Reference in New Issue