diff --git a/cmd/litestream/databases.go b/cmd/litestream/databases.go index eac0dff..eb7916d 100644 --- a/cmd/litestream/databases.go +++ b/cmd/litestream/databases.go @@ -35,7 +35,9 @@ func (c *DatabasesCommand) Run(ctx context.Context, args []string) (err error) { } // List all databases. - w := tabwriter.NewWriter(os.Stdout, 0, 8, 1, '\t', 0) + w := tabwriter.NewWriter(os.Stdout, 0, 8, 2, ' ', 0) + defer w.Flush() + fmt.Fprintln(w, "path\treplicas") for _, dbConfig := range config.DBs { db, err := newDBFromConfig(&config, dbConfig) @@ -53,7 +55,6 @@ func (c *DatabasesCommand) Run(ctx context.Context, args []string) (err error) { strings.Join(replicaNames, ","), ) } - w.Flush() return nil } diff --git a/cmd/litestream/generations.go b/cmd/litestream/generations.go index 32ece70..ca9481f 100644 --- a/cmd/litestream/generations.go +++ b/cmd/litestream/generations.go @@ -77,7 +77,9 @@ func (c *GenerationsCommand) Run(ctx context.Context, args []string) (err error) } // List each generation. - w := tabwriter.NewWriter(os.Stdout, 0, 8, 1, '\t', 0) + w := tabwriter.NewWriter(os.Stdout, 0, 8, 2, ' ', 0) + defer w.Flush() + fmt.Fprintln(w, "name\tgeneration\tlag\tstart\tend") for _, r := range replicas { generations, err := r.Generations(ctx) @@ -101,10 +103,8 @@ func (c *GenerationsCommand) Run(ctx context.Context, args []string) (err error) stats.CreatedAt.Format(time.RFC3339), stats.UpdatedAt.Format(time.RFC3339), ) - w.Flush() } } - w.Flush() return nil } diff --git a/cmd/litestream/snapshots.go b/cmd/litestream/snapshots.go index 55a0e41..52a71d8 100644 --- a/cmd/litestream/snapshots.go +++ b/cmd/litestream/snapshots.go @@ -75,7 +75,9 @@ func (c *SnapshotsCommand) Run(ctx context.Context, args []string) (err error) { } // List all snapshots. - w := tabwriter.NewWriter(os.Stdout, 0, 8, 1, '\t', 0) + w := tabwriter.NewWriter(os.Stdout, 0, 8, 2, ' ', 0) + defer w.Flush() + fmt.Fprintln(w, "replica\tgeneration\tindex\tsize\tcreated") for _, info := range infos { fmt.Fprintf(w, "%s\t%s\t%d\t%d\t%s\n", @@ -86,7 +88,6 @@ func (c *SnapshotsCommand) Run(ctx context.Context, args []string) (err error) { info.CreatedAt.Format(time.RFC3339), ) } - w.Flush() return nil } diff --git a/cmd/litestream/wal.go b/cmd/litestream/wal.go index a71a574..1d7bf41 100644 --- a/cmd/litestream/wal.go +++ b/cmd/litestream/wal.go @@ -76,7 +76,9 @@ func (c *WALCommand) Run(ctx context.Context, args []string) (err error) { } // List all WAL files. - w := tabwriter.NewWriter(os.Stdout, 0, 8, 1, '\t', 0) + w := tabwriter.NewWriter(os.Stdout, 0, 8, 2, ' ', 0) + defer w.Flush() + fmt.Fprintln(w, "replica\tgeneration\tindex\toffset\tsize\tcreated") for _, info := range infos { if *generation != "" && info.Generation != *generation { @@ -92,7 +94,6 @@ func (c *WALCommand) Run(ctx context.Context, args []string) (err error) { info.CreatedAt.Format(time.RFC3339), ) } - w.Flush() return nil }