@cryptotaxi247 / kubo / commits / 8aa3e51e7

Added Default to `diag` cmd

Part of #2484. License: MIT Signed-off-by: Richard Littauer <richard.littauer@gmail.com>

Richard Littauer committed May 11, 2016 at 16:10 UTC 8aa3e51e7801a09e6fc82802ad070660a2cfa341
1 file changed +10 -6
core/commands/diag.go
+10 -6
@@ -22,7 +22,8 @@ type DiagnosticConnection struct {
22 var (
23 visD3 = "d3"
24 visDot = "dot"
25 - visFmts = []string{visD3, visDot}
25 + visText = "text"
26 + visFmts = []string{visD3, visDot, visText}
27 )
28
29 type DiagnosticPeer struct {
@@ -66,8 +67,8 @@ timeout. If the timeout is too small, some peers may not be reached.
67 The default timeout is 20 seconds.
68
69 The 'vis' option may be used to change the output format.
69 -Four formats are supported:
70 - * plain text - Easy to read. Default.
70 +Three formats are supported:
71 + * text - Easy to read. Default.
72 * d3 - json ready to be fed into d3view
73 * dot - graphviz format
74
@@ -81,13 +82,13 @@ open the following link:
82
83 http://gateway.ipfs.io/ipfs/QmbesKpGyQGd5jtJFUGEB1ByPjNFpukhnKZDnkfxUiKn38/chord#<your hash>
84
84 -The dot format can be fed into graphviz and other programs
85 +The 'dot' format can be fed into graphviz and other programs
86 that consume the dot format to generate graphs of the network.
87 `,
88 },
89
90 Options: []cmds.Option{
90 - cmds.StringOption("vis", "Output vis. One of: "+strings.Join(visFmts, ", ")),
91 + cmds.StringOption("vis", "Output format. One of: "+strings.Join(visFmts, ", ")).Default(visText),
92 },
93
94 Run: func(req cmds.Request, res cmds.Response) {
@@ -141,13 +142,16 @@ that consume the dot format to generate graphs of the network.
142 return
143 }
144 res.SetOutput(io.Reader(buf))
144 - default:
145 + case visText:
146 output, err := stdDiagOutputMarshal(standardDiagOutput(info))
147 if err != nil {
148 res.SetError(err, cmds.ErrNormal)
149 return
150 }
151 res.SetOutput(output)
152 + default:
153 + res.SetError(err, cmds.ErrNormal)
154 + return
155 }
156 },
157 }