mirror of
https://github.com/kopia/kopia.git
synced 2026-01-23 05:47:57 -05:00
34 lines
579 B
Go
34 lines
579 B
Go
package cli
|
|
|
|
import (
|
|
"io"
|
|
"os"
|
|
|
|
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
|
)
|
|
|
|
var (
|
|
catCommand = app.Command("cat", "Displays contents of a repository object.")
|
|
catCommandPath = catCommand.Arg("path", "Path").Required().String()
|
|
)
|
|
|
|
func runCatCommand(context *kingpin.ParseContext) error {
|
|
conn := mustOpenConnection()
|
|
defer conn.Close()
|
|
|
|
oid, err := parseObjectID(*catCommandPath, conn)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
r, err := conn.Open(oid)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
io.Copy(os.Stdout, r)
|
|
return nil
|
|
}
|
|
|
|
func init() {
|
|
catCommand.Action(runCatCommand)
|
|
}
|