mirror of
https://github.com/octoleo/restic.git
synced 2024-12-22 02:48:55 +00:00
Add command 'list'
This commit is contained in:
parent
11d6aa5328
commit
5cbd1d0090
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["backup"] = commandBackup
|
||||
commands["restore"] = commandRestore
|
||||
commands["list"] = commandList
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
Loading…
Reference in New Issue
Block a user