mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-12 11:48:07 +08:00
core/commands: Added more advanced test subcommand
This commit is contained in:
parent
3ae6117c5b
commit
3d0ca14b96
@ -1,6 +1,7 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
cmds "github.com/jbenet/go-ipfs/commands"
|
||||
"strings"
|
||||
)
|
||||
@ -52,5 +53,24 @@ Use "ipfs help <command>" for more information about a command.
|
||||
res.SetValue(v)
|
||||
},
|
||||
},
|
||||
"warp": &cmds.Command{
|
||||
Options: []cmds.Option{
|
||||
cmds.Option{[]string{"power", "p"}, cmds.Float},
|
||||
},
|
||||
Run: func(req cmds.Request, res cmds.Response) {
|
||||
threshold := 1.21
|
||||
|
||||
if power, found := req.Option("power"); found && power.(float64) >= threshold {
|
||||
res.SetValue(struct {
|
||||
Status string
|
||||
Power float64
|
||||
}{"Flux capacitor activated!", power.(float64)})
|
||||
|
||||
} else {
|
||||
err := fmt.Errorf("Insufficient power (%v jiggawatts required)", threshold)
|
||||
res.SetError(err, cmds.ErrClient)
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user