mirror of
https://github.com/kopia/kopia.git
synced 2026-03-15 04:38:56 -04:00
36 lines
786 B
Go
36 lines
786 B
Go
package cli
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
|
|
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
|
)
|
|
|
|
var (
|
|
blockIndexShowCommand = blockIndexCommands.Command("show", "List block indexes").Alias("cat")
|
|
blockIndexShowIDs = blockIndexShowCommand.Arg("id", "IDs of index blocks to show").Required().Strings()
|
|
)
|
|
|
|
func runShowBlockIndexesAction(context *kingpin.ParseContext) error {
|
|
rep := mustOpenRepository(nil)
|
|
defer rep.Close()
|
|
|
|
for _, blockID := range *blockIndexShowIDs {
|
|
data, err := rep.Blocks.GetBlock(blockID)
|
|
if err != nil {
|
|
return fmt.Errorf("can't read block %q: %v", blockID, err)
|
|
}
|
|
|
|
if err := showContentWithFlags(bytes.NewReader(data), true, true); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func init() {
|
|
blockIndexShowCommand.Action(runShowBlockIndexesAction)
|
|
}
|