mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-01 19:24:14 +08:00
Merge pull request #2664 from ipfs/feature/add-default-to-diag
Added Default to `diag` cmd
This commit is contained in:
@ -22,7 +22,8 @@ type DiagnosticConnection struct {
|
|||||||
var (
|
var (
|
||||||
visD3 = "d3"
|
visD3 = "d3"
|
||||||
visDot = "dot"
|
visDot = "dot"
|
||||||
visFmts = []string{visD3, visDot}
|
visText = "text"
|
||||||
|
visFmts = []string{visD3, visDot, visText}
|
||||||
)
|
)
|
||||||
|
|
||||||
type DiagnosticPeer struct {
|
type DiagnosticPeer struct {
|
||||||
@ -66,8 +67,8 @@ timeout. If the timeout is too small, some peers may not be reached.
|
|||||||
The default timeout is 20 seconds.
|
The default timeout is 20 seconds.
|
||||||
|
|
||||||
The 'vis' option may be used to change the output format.
|
The 'vis' option may be used to change the output format.
|
||||||
Four formats are supported:
|
Three formats are supported:
|
||||||
* plain text - Easy to read. Default.
|
* text - Easy to read. Default.
|
||||||
* d3 - json ready to be fed into d3view
|
* d3 - json ready to be fed into d3view
|
||||||
* dot - graphviz format
|
* dot - graphviz format
|
||||||
|
|
||||||
@ -81,13 +82,13 @@ open the following link:
|
|||||||
|
|
||||||
http://gateway.ipfs.io/ipfs/QmbesKpGyQGd5jtJFUGEB1ByPjNFpukhnKZDnkfxUiKn38/chord#<your hash>
|
http://gateway.ipfs.io/ipfs/QmbesKpGyQGd5jtJFUGEB1ByPjNFpukhnKZDnkfxUiKn38/chord#<your hash>
|
||||||
|
|
||||||
The dot format can be fed into graphviz and other programs
|
The 'dot' format can be fed into graphviz and other programs
|
||||||
that consume the dot format to generate graphs of the network.
|
that consume the dot format to generate graphs of the network.
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
|
|
||||||
Options: []cmds.Option{
|
Options: []cmds.Option{
|
||||||
cmds.StringOption("vis", "Output vis. One of: "+strings.Join(visFmts, ", ")),
|
cmds.StringOption("vis", "Output format. One of: "+strings.Join(visFmts, ", ")).Default(visText),
|
||||||
},
|
},
|
||||||
|
|
||||||
Run: func(req cmds.Request, res cmds.Response) {
|
Run: func(req cmds.Request, res cmds.Response) {
|
||||||
@ -141,13 +142,16 @@ that consume the dot format to generate graphs of the network.
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
res.SetOutput(io.Reader(buf))
|
res.SetOutput(io.Reader(buf))
|
||||||
default:
|
case visText:
|
||||||
output, err := stdDiagOutputMarshal(standardDiagOutput(info))
|
output, err := stdDiagOutputMarshal(standardDiagOutput(info))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.SetError(err, cmds.ErrNormal)
|
res.SetError(err, cmds.ErrNormal)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
res.SetOutput(output)
|
res.SetOutput(output)
|
||||||
|
default:
|
||||||
|
res.SetError(err, cmds.ErrNormal)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user