added new cli flags to 'storage list'

This commit is contained in:
Jarek Kowalski committed 2018-06-02 10:46:59 -07:00
1 parent 5ba913380e
commit 02c5e90671
1 file changed
+10
+10
View File
@@ -10,6 +10,8 @@ import (
var (
storageListCommand = storageCommands.Command("list", "List storage blocks").Alias("ls")
storageListPrefix = storageListCommand.Flag("prefix", "Block prefix").String()
storageListMinSize = storageListCommand.Flag("min-size", "Minimum size").Int64()
storageListMaxSize = storageListCommand.Flag("max-size", "Maximum size").Int64()
)
func runListStorageBlocks(ctx context.Context, rep *repo.Repository) error {
@@ -22,6 +24,14 @@ func runListStorageBlocks(ctx context.Context, rep *repo.Repository) error {
return b.Error
}
if *storageListMaxSize != 0 && b.Length > *storageListMaxSize {
continue
}
if *storageListMinSize != 0 && b.Length < *storageListMinSize {
continue
}
fmt.Printf("%-70v %10v %v\n", b.BlockID, b.Length, b.TimeStamp.Local().Format(timeFormat))
}