mirror of
https://github.com/kopia/kopia.git
synced 2026-01-25 06:48:48 -05:00
35 lines
708 B
Go
35 lines
708 B
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
|
)
|
|
|
|
var (
|
|
storageListCommand = storageCommands.Command("list", "List storage blocks").Alias("ls")
|
|
storageListPrefix = storageListCommand.Flag("prefix", "Block prefix").String()
|
|
)
|
|
|
|
func runListStorageBlocks(context *kingpin.ParseContext) error {
|
|
rep := mustOpenRepository(nil)
|
|
defer rep.Close() //nolint: errcheck
|
|
|
|
ch, cancel := rep.Storage.ListBlocks(*storageListPrefix)
|
|
defer cancel()
|
|
|
|
for b := range ch {
|
|
if b.Error != nil {
|
|
return b.Error
|
|
}
|
|
|
|
fmt.Printf("%-70v %10v %v\n", b.BlockID, b.Length, b.TimeStamp.Local().Format(timeFormat))
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func init() {
|
|
storageListCommand.Action(runListStorageBlocks)
|
|
}
|