mirror of
https://github.com/kopia/kopia.git
synced 2026-01-24 22:38:00 -05:00
36 lines
741 B
Go
36 lines
741 B
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/kopia/repo"
|
|
)
|
|
|
|
var (
|
|
blockIndexListCommand = blockIndexCommands.Command("list", "List block indexes").Alias("ls").Default()
|
|
blockIndexListSummary = blockIndexListCommand.Flag("summary", "Display block summary").Bool()
|
|
)
|
|
|
|
func runListBlockIndexesAction(ctx context.Context, rep *repo.Repository) error {
|
|
blks, err := rep.Blocks.IndexBlocks(ctx)
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, b := range blks {
|
|
fmt.Printf("%-70v %10v %v\n", b.FileName, b.Length, formatTimestampPrecise(b.Timestamp))
|
|
}
|
|
|
|
if *blockIndexListSummary {
|
|
fmt.Printf("total %v blocks\n", len(blks))
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func init() {
|
|
blockIndexListCommand.Action(repositoryAction(runListBlockIndexesAction))
|
|
}
|