summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-06-14 14:15:47 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-06-25 22:26:06 +0900
commit01e71c81006bb59c2b30bf026873666ced45158f (patch)
tree74cb2bd935dc3dde944376b8b68c36b4ab5ff43b
parentef51565a5eb91e7af7519eb75a365afcf6f84922 (diff)
cli: handle json option for monitor commands
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
-rw-r--r--gobgp/monitor.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/gobgp/monitor.go b/gobgp/monitor.go
index 578162ce..d21de0f3 100644
--- a/gobgp/monitor.go
+++ b/gobgp/monitor.go
@@ -16,6 +16,7 @@
package main
import (
+ "encoding/json"
"fmt"
"github.com/osrg/gobgp/api"
"github.com/spf13/cobra"
@@ -52,7 +53,12 @@ func NewMonitorCmd() *cobra.Command {
fmt.Println(err)
os.Exit(1)
}
- showRoute([]*api.Path{p}, false, false, true)
+ if globalOpts.Json {
+ j, _ := json.Marshal(p)
+ fmt.Println(string(j))
+ } else {
+ showRoute([]*api.Path{p}, false, false, true)
+ }
}
},
@@ -88,7 +94,12 @@ func NewMonitorCmd() *cobra.Command {
fmt.Println(err)
os.Exit(1)
}
- fmt.Printf("[NEIGH] %s fsm: %s admin: %s\n", s.Conf.RemoteIp, s.Info.BgpState, s.Info.AdminState)
+ if globalOpts.Json {
+ j, _ := json.Marshal(s)
+ fmt.Println(string(j))
+ } else {
+ fmt.Printf("[NEIGH] %s fsm: %s admin: %s\n", s.Conf.RemoteIp, s.Info.BgpState, s.Info.AdminState)
+ }
}
},
}