2
2
mirror of https://github.com/octoleo/restic.git synced 2024-06-04 01:50:48 +00:00
restic/cmd/stat/stat.go
Alexander Neumann 2428843faa Refactor
2014-08-11 22:47:24 +02:00

38 lines
595 B
Go

package main
import (
"encoding/json"
"fmt"
"os"
"github.com/fd0/khepri"
)
func main() {
if len(os.Args) == 1 {
fmt.Printf("usage: %s [file] [file] [...]\n", os.Args[0])
os.Exit(1)
}
for _, path := range os.Args[1:] {
fmt.Printf("lstat %s\n", path)
fi, err := os.Lstat(path)
if err != nil {
fmt.Fprintf(os.Stderr, "%v", err)
continue
}
node, err := khepri.NodeFromFileInfo(path, fi)
if err != nil {
fmt.Printf("err: %v\n", err)
}
buf, err := json.MarshalIndent(node, "", " ")
if err != nil {
panic(err)
}
fmt.Printf("%s\n", string(buf))
}
}