From e64ffb9ab3fd6562b4c3d165f370869f7713c6e7 Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Wed, 22 Oct 2014 15:25:41 -0700 Subject: [PATCH] core/commands: Added root command (with test subcommands) --- core/commands/root.go | 56 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 core/commands/root.go diff --git a/core/commands/root.go b/core/commands/root.go new file mode 100644 index 000000000..608edf403 --- /dev/null +++ b/core/commands/root.go @@ -0,0 +1,56 @@ +package commands + +import ( + cmds "github.com/jbenet/go-ipfs/commands" + "strings" +) + +type TestOutput struct { + Foo string + Bar int +} + +var Root = &cmds.Command{ + Options: []cmds.Option{ + cmds.Option{[]string{"config", "c"}, cmds.String}, + cmds.Option{[]string{"debug", "D"}, cmds.Bool}, + }, + Help: `ipfs - global versioned p2p merkledag file system + +Basic commands: + + init Initialize ipfs local configuration. + add Add an object to ipfs. + cat Show ipfs object data. + ls List links from an object. + refs List link hashes from an object. + +Tool commands: + + config Manage configuration. + version Show ipfs version information. + commands List all available commands. + +Advanced Commands: + + mount Mount an ipfs read-only mountpoint. + serve Serve an interface to ipfs. + net-diag Print network diagnostic. + +Use "ipfs help " for more information about a command. +`, + Subcommands: map[string]*cmds.Command{ + "beep": &cmds.Command{ + Run: func(req cmds.Request, res cmds.Response) { + v := TestOutput{"hello, world", 1337} + res.SetValue(v) + }, + }, + "boop": &cmds.Command{ + Run: func(req cmds.Request, res cmds.Response) { + v := strings.NewReader("hello, world") + res.SetValue(v) + }, + }, + }, +}