restic: Add 'cat config' command

This commit is contained in:
Alexander Neumann 2015-05-03 17:37:21 +02:00
parent d4bf5bb279
commit 765e3dc66f

View file

@ -27,11 +27,11 @@ func init() {
}
func (cmd CmdCat) Usage() string {
return "[pack|blob|tree|snapshot|key|masterkey|lock] ID"
return "[pack|blob|tree|snapshot|key|masterkey|config|lock] ID"
}
func (cmd CmdCat) Execute(args []string) error {
if len(args) < 1 || (args[0] != "masterkey" && len(args) != 2) {
if len(args) < 1 || (args[0] != "masterkey" && args[0] != "config" && len(args) != 2) {
return fmt.Errorf("type or ID not specified, Usage: %s", cmd.Usage())
}
@ -43,7 +43,7 @@ func (cmd CmdCat) Execute(args []string) error {
tpe := args[0]
var id backend.ID
if tpe != "masterkey" {
if tpe != "masterkey" && tpe != "config" {
id, err = backend.ParseID(args[1])
if err != nil {
id = nil
@ -67,6 +67,14 @@ func (cmd CmdCat) Execute(args []string) error {
// handle all types that don't need an index
switch tpe {
case "config":
buf, err := json.MarshalIndent(s.Config, "", " ")
if err != nil {
return err
}
fmt.Println(string(buf))
return nil
case "index":
buf, err := s.Load(backend.Index, id)
if err != nil {