Update date format, add status to view
This commit is contained in:
parent
647b38ccb8
commit
bcd08235a3
4
main.go
4
main.go
|
@ -69,9 +69,9 @@ func fetchQueueEntries() ([]parser.QEntry, error) {
|
||||||
|
|
||||||
func printQueueEntries(entries []parser.QEntry, writer io.Writer) {
|
func printQueueEntries(entries []parser.QEntry, writer io.Writer) {
|
||||||
tabWriter := tabwriter.NewWriter(writer, 2, 2, 1, ' ', tabwriter.TabIndent)
|
tabWriter := tabwriter.NewWriter(writer, 2, 2, 1, ' ', tabwriter.TabIndent)
|
||||||
fmt.Fprintf(tabWriter, "| %s\t| %s\t| %s\t| %s\t| %s\t| %s\t| %s\t| \n", "Date", "Id", "Size", "Sender", "#", "First Recipient", "Reason")
|
fmt.Fprintf(tabWriter, "| %s\t| %s\t| %s\t| %s\t| %s\t| %s\t| %s\t| %s\t| \n", "Date", "Id", "Status", "Size", "Sender", "#", "First Recipient", "Reason")
|
||||||
for _, entry := range entries {
|
for _, entry := range entries {
|
||||||
_, writeError := fmt.Fprintf(tabWriter, "| %s\t| %s\t| %d\t| %s\t| {%d}\t| %s\t| %s\t \n", entry.Date, entry.Id, entry.Size, entry.Sender, len(entry.Recipients), entry.Recipients[0], entry.Reason)
|
_, writeError := fmt.Fprintf(tabWriter, "| %s\t| %s\t| %s\t| %d\t| %s\t| {%d}\t| %s\t| %s\t \n", entry.Date.Format(parser.SortableDateFormat), entry.Id, entry.Status, entry.Size, entry.Sender, len(entry.Recipients), entry.Recipients[0], entry.Reason)
|
||||||
if writeError != nil {
|
if writeError != nil {
|
||||||
// A writeError is expected once the reader was closed
|
// A writeError is expected once the reader was closed
|
||||||
// This happens when the pager application got terminated
|
// This happens when the pager application got terminated
|
||||||
|
|
|
@ -21,10 +21,10 @@ type QEntry struct {
|
||||||
Reason string
|
Reason string
|
||||||
}
|
}
|
||||||
|
|
||||||
const sortableDateFormat = "2006-01-02 15:04:05"
|
const SortableDateFormat = "2006-01-02 15:04:05"
|
||||||
|
|
||||||
func (m QEntry) ShortString() string {
|
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)
|
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 {
|
func (m QEntry) String() string {
|
||||||
|
@ -32,7 +32,7 @@ func (m QEntry) String() string {
|
||||||
if len(m.Recipients) > 1 {
|
if len(m.Recipients) > 1 {
|
||||||
recipientSuffix = ",..."
|
recipientSuffix = ",..."
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("[%s] %s <%s> -> {%d}<%s>%s (%s, %d bytes)", m.Date.Format(sortableDateFormat), m.Id, m.Sender, len(m.Recipients), m.Recipients[0], recipientSuffix, m.Status, m.Size)
|
return fmt.Sprintf("[%s] %s <%s> -> {%d}<%s>%s (%s, %d bytes)", m.Date.Format(SortableDateFormat), m.Id, m.Sender, len(m.Recipients), m.Recipients[0], recipientSuffix, m.Status, m.Size)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m QEntry) DetailedString() string {
|
func (m QEntry) DetailedString() string {
|
||||||
|
@ -40,7 +40,7 @@ func (m QEntry) DetailedString() string {
|
||||||
if m.Reason == "" {
|
if m.Reason == "" {
|
||||||
reasonStr = "-/-"
|
reasonStr = "-/-"
|
||||||
}
|
}
|
||||||
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, reasonStr, m.Size, m.Sender, strings.Join(m.Recipients, ", "))
|
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, reasonStr, m.Size, m.Sender, strings.Join(m.Recipients, ", "))
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseMailQ(dataSource io.Reader) ([]QEntry, error) {
|
func ParseMailQ(dataSource io.Reader) ([]QEntry, error) {
|
||||||
|
|
Loading…
Reference in New Issue