Add command 'list'

This commit is contained in:
Alexander Neumann 2014-08-01 22:20:28 +02:00
parent 11d6aa5328
commit 5cbd1d0090
2 changed files with 30 additions and 0 deletions

29
cmd/khepri/cmd_list.go Normal file
View 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
}

View File

@ -30,6 +30,7 @@ func init() {
commands = make(map[string]commandFunc)
commands["backup"] = commandBackup
commands["restore"] = commandRestore
commands["list"] = commandList
}
func main() {