mirror of
https://github.com/kopia/kopia.git
synced 2026-01-25 06:48:48 -05:00
33 lines
665 B
Go
33 lines
665 B
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
|
)
|
|
|
|
var (
|
|
objectListCommand = objectCommands.Command("list", "List objects").Alias("ls")
|
|
objectListPrefix = objectListCommand.Flag("prefix", "Prefix").String()
|
|
)
|
|
|
|
func runListObjectsAction(context *kingpin.ParseContext) error {
|
|
rep := mustOpenRepository(nil)
|
|
defer rep.Close() //nolint: errcheck
|
|
|
|
info, err := rep.Blocks.ListBlocks(*objectListPrefix)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, b := range info {
|
|
fmt.Printf("D%-34v %10v %v\n", b.BlockID, b.Length, b.Timestamp.Local().Format(timeFormat))
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func init() {
|
|
objectListCommand.Action(runListObjectsAction)
|
|
}
|