提交 3d0ca14b 作者: Matt Bell 提交者: Juan Batiz-Benet

core/commands: Added more advanced test subcommand

上级 3ae6117c
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)
}
},
},
},
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论