mirror of
https://github.com/kopia/kopia.git
synced 2026-01-26 15:28:06 -05:00
* restore: improved user experience * 'snapshot restore' is now the same as 'restore' and both will support restoring by manifest ID, root ID or root ID + subdirectory * added support for restoring individual files * implemented PR feedback and refactored object ID parsing Moving helpers inside the snapshot/ package helped clean up the code a lot.
38 lines
745 B
Go
38 lines
745 B
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
|
|
"github.com/kopia/kopia/internal/iocopy"
|
|
"github.com/kopia/kopia/repo"
|
|
"github.com/kopia/kopia/snapshot/snapshotfs"
|
|
)
|
|
|
|
var (
|
|
catCommand = app.Command("show", "Displays contents of a repository object.").Alias("cat")
|
|
catCommandPath = catCommand.Arg("object-path", "Path").Required().String()
|
|
)
|
|
|
|
func runCatCommand(ctx context.Context, rep repo.Repository) error {
|
|
oid, err := snapshotfs.ParseObjectIDWithPath(ctx, rep, *catCommandPath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
r, err := rep.OpenObject(ctx, oid)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
defer r.Close() //nolint:errcheck
|
|
|
|
_, err = iocopy.Copy(os.Stdout, r)
|
|
|
|
return err
|
|
}
|
|
|
|
func init() {
|
|
catCommand.Action(repositoryAction(runCatCommand))
|
|
}
|