core/commands: Added root command (with test subcommands)
Matt Bell committed
Oct 22, 2014 at 15:25 UTC
e64ffb9ab3fd6562b4c3d165f370869f7713c6e7
1 file changed
+56
core/commands/root.go
new
+56
@@ -0,0 +1,56 @@
1
+package commands
2
+
3
+import (
4
+ cmds "github.com/jbenet/go-ipfs/commands"
5
+ "strings"
6
+)
7
+
8
+type TestOutput struct {
9
+ Foo string
10
+ Bar int
11
+}
12
+
13
+var Root = &cmds.Command{
14
+ Options: []cmds.Option{
15
+ cmds.Option{[]string{"config", "c"}, cmds.String},
16
+ cmds.Option{[]string{"debug", "D"}, cmds.Bool},
17
+ },
18
+ Help: `ipfs - global versioned p2p merkledag file system
19
+
20
+Basic commands:
21
+
22
+ init Initialize ipfs local configuration.
23
+ add <path> Add an object to ipfs.
24
+ cat <ref> Show ipfs object data.
25
+ ls <ref> List links from an object.
26
+ refs <ref> List link hashes from an object.
27
+
28
+Tool commands:
29
+
30
+ config Manage configuration.
31
+ version Show ipfs version information.
32
+ commands List all available commands.
33
+
34
+Advanced Commands:
35
+
36
+ mount Mount an ipfs read-only mountpoint.
37
+ serve Serve an interface to ipfs.
38
+ net-diag Print network diagnostic.
39
+
40
+Use "ipfs help <command>" for more information about a command.
41
+`,
42
+ Subcommands: map[string]*cmds.Command{
43
+ "beep": &cmds.Command{
44
+ Run: func(req cmds.Request, res cmds.Response) {
45
+ v := TestOutput{"hello, world", 1337}
46
+ res.SetValue(v)
47
+ },
48
+ },
49
+ "boop": &cmds.Command{
50
+ Run: func(req cmds.Request, res cmds.Response) {
51
+ v := strings.NewReader("hello, world")
52
+ res.SetValue(v)
53
+ },
54
+ },
55
+ },
56
+}