mirror of
https://github.com/kopia/kopia.git
synced 2026-10-23 06:38:42 -04:00
added 'object list' subcommand
This commit is contained in:
1 parent
4b77119736
commit
1e0ef911fa
1 file changed
+41
@@ -0,0 +1,41 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/kopia/kopia/repo"
|
||||
|
||||
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()
|
||||
|
||||
ch, cancel := rep.Storage.ListBlocks(*objectListPrefix)
|
||||
defer cancel()
|
||||
|
||||
for b := range ch {
|
||||
if b.Error != nil {
|
||||
return b.Error
|
||||
}
|
||||
|
||||
if strings.HasPrefix(b.BlockID, repo.MetadataBlockPrefix) {
|
||||
continue
|
||||
}
|
||||
|
||||
fmt.Printf("D%v\n", b.BlockID)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
objectListCommand.Action(runListObjectsAction)
|
||||
}
|
||||
Reference in new issue
Block a user