From 3d0ca14b96ff21ac614365ab9ecd39a91eb4b176 Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Wed, 22 Oct 2014 16:02:12 -0700 Subject: [PATCH] core/commands: Added more advanced test subcommand --- core/commands/root.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/core/commands/root.go b/core/commands/root.go index 608edf403..69d093281 100644 --- a/core/commands/root.go +++ b/core/commands/root.go @@ -1,6 +1,7 @@ package commands import ( + "fmt" cmds "github.com/jbenet/go-ipfs/commands" "strings" ) @@ -52,5 +53,24 @@ Use "ipfs help " 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) + } + }, + }, }, }