forked from TrueCloudLab/restic
Add command 'list'
This commit is contained in:
parent
11d6aa5328
commit
5cbd1d0090
2 changed files with 30 additions and 0 deletions
29
cmd/khepri/cmd_list.go
Normal file
29
cmd/khepri/cmd_list.go
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/fd0/khepri"
|
||||||
|
)
|
||||||
|
|
||||||
|
func commandList(repo *khepri.DirRepository, args []string) error {
|
||||||
|
if len(args) != 1 {
|
||||||
|
return errors.New("usage: list [blob|ref]")
|
||||||
|
}
|
||||||
|
|
||||||
|
tpe := khepri.NewTypeFromString(args[0])
|
||||||
|
|
||||||
|
ids, err := repo.ListIDs(tpe)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "error: %v\n", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, id := range ids {
|
||||||
|
fmt.Printf("%v\n", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -30,6 +30,7 @@ func init() {
|
||||||
commands = make(map[string]commandFunc)
|
commands = make(map[string]commandFunc)
|
||||||
commands["backup"] = commandBackup
|
commands["backup"] = commandBackup
|
||||||
commands["restore"] = commandRestore
|
commands["restore"] = commandRestore
|
||||||
|
commands["list"] = commandList
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
Loading…
Reference in a new issue