mirror of
https://github.com/kopia/kopia.git
synced 2026-01-26 23:38:04 -05:00
* linter: upgraded to 1.33, disabled some linters * lint: fixed 'errorlint' errors This ensures that all error comparisons use errors.Is() or errors.As(). We will be wrapping more errors going forward so it's important that error checks are not strict everywhere. Verified that there are no exceptions for errorlint linter which guarantees that. * lint: fixed or suppressed wrapcheck errors * lint: nolintlint and misc cleanups Co-authored-by: Julio López <julio+gh@kasten.io>
42 lines
983 B
Go
42 lines
983 B
Go
package cli
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/kopia/kopia/repo"
|
|
"github.com/kopia/kopia/repo/content"
|
|
)
|
|
|
|
var (
|
|
contentShowCommand = contentCommands.Command("show", "Show contents by ID.").Alias("cat")
|
|
|
|
contentShowIDs = contentShowCommand.Arg("id", "IDs of contents to show").Required().Strings()
|
|
)
|
|
|
|
func runContentShowCommand(ctx context.Context, rep *repo.DirectRepository) error {
|
|
for _, contentID := range toContentIDs(*contentShowIDs) {
|
|
if err := contentShow(ctx, rep, contentID); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func contentShow(ctx context.Context, r *repo.DirectRepository, contentID content.ID) error {
|
|
data, err := r.Content.GetContent(ctx, contentID)
|
|
if err != nil {
|
|
return errors.Wrapf(err, "error getting content %v", contentID)
|
|
}
|
|
|
|
return showContent(bytes.NewReader(data))
|
|
}
|
|
|
|
func init() {
|
|
setupShowCommand(contentShowCommand)
|
|
contentShowCommand.Action(directRepositoryAction(runContentShowCommand))
|
|
}
|