diff --git a/main.go b/main.go index 19c3d97..6e638cd 100644 --- a/main.go +++ b/main.go @@ -36,14 +36,12 @@ func main() { flag.PrintDefaults() os.Exit(1) } - if err != nil { fmt.Printf("Error reading: %s\n", err.Error()) os.Exit(1) } - - for _, line := range entries { - fmt.Printf("Read: %s", line) + for _, entry := range entries { + fmt.Printf("%s\n", entry.String()) } } diff --git a/parser/parser.go b/parser/parser.go index abfd1b7..4964a78 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -21,8 +21,18 @@ type QEntry struct { reason string } +const sortableDateFormat = "2006-01-02 15:04:05" + +func (m QEntry) ShortString() string { + return fmt.Sprintf("[%s] %s <%s> -> %d recipients (%d bytes)", m.date.Format(sortableDateFormat), m.id, m.sender, len(m.recipients), m.size) +} + func (m QEntry) String() string { - return fmt.Sprintf("ID: %s, Status: %s, Size: %d bytes, Sender: %s, Recipients: %d", m.id, m.status, m.size, m.sender, len(m.recipients)) + return fmt.Sprintf("[%s] %s <%s> -> %d recipients (%s, %d bytes)", m.date.Format(sortableDateFormat), m.id, m.sender, len(m.recipients), m.status, m.size) +} + +func (m QEntry) DetailedString() string { + return fmt.Sprintf("Id: %s\nDate: %s\nStatus: %s\nReason: %s\nSize: %d\nSender: %s\nRecipients: %s", m.id, m.date.Format(sortableDateFormat), m.status, m.reason, m.size, m.sender, strings.Join(m.recipients, ", ")) } func ParseMailQ(dataSource io.Reader) ([]QEntry, error) {