Show the amount of snapshots

This commit is contained in:
Jannick Fahlbusch 2017-10-01 17:13:58 +02:00
parent 3afd974dea
commit 2f10e25738
No known key found for this signature in database
GPG Key ID: B6F3B49B350D87BD
2 changed files with 20 additions and 1 deletions

View File

@ -163,6 +163,8 @@ func PrintSnapshots(stdout io.Writer, list restic.Snapshots, compact bool) {
}
}
tab.Footer = fmt.Sprintf("Amount of snapshots: %d", len(list))
tab.Write(stdout)
}

View File

@ -10,6 +10,7 @@ import (
type Table struct {
Header string
Rows [][]interface{}
Footer string
RowFormat string
}
@ -21,13 +22,19 @@ func NewTable() Table {
}
}
func (t Table) printSeparationLine(w io.Writer) error {
_, err := fmt.Fprintln(w, strings.Repeat("-", 70))
return err
}
// Write prints the table to w.
func (t Table) Write(w io.Writer) error {
_, err := fmt.Fprintln(w, t.Header)
if err != nil {
return err
}
_, err = fmt.Fprintln(w, strings.Repeat("-", 70))
err = t.printSeparationLine(w)
if err != nil {
return err
}
@ -39,6 +46,16 @@ func (t Table) Write(w io.Writer) error {
}
}
err = t.printSeparationLine(w)
if err != nil {
return err
}
_, err = fmt.Fprintln(w, t.Footer)
if err != nil {
return err
}
return nil
}