From 2f10e2573841314f76501bc6eba848db00fd56dd Mon Sep 17 00:00:00 2001 From: Jannick Fahlbusch Date: Sun, 1 Oct 2017 17:13:58 +0200 Subject: [PATCH] Show the amount of snapshots --- cmd/restic/cmd_snapshots.go | 2 ++ cmd/restic/table.go | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/cmd/restic/cmd_snapshots.go b/cmd/restic/cmd_snapshots.go index 7bac53131..7f5152216 100644 --- a/cmd/restic/cmd_snapshots.go +++ b/cmd/restic/cmd_snapshots.go @@ -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) } diff --git a/cmd/restic/table.go b/cmd/restic/table.go index 7a5d17a53..b2fa772f8 100644 --- a/cmd/restic/table.go +++ b/cmd/restic/table.go @@ -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 }