cmd/ipfs: Reverted back to secondary CLI root command
Matt Bell committed
Oct 31, 2014 at 13:55 UTC
cac8844b8d88e1ab6eca68501546a1b309a6f0f6
5 files changed
+24
-12
cmd/ipfs2/daemon.go
renamed
+3
-3
@@ -1,4 +1,4 @@
1
-package commands
1
+package main
2
3
import (
4
"fmt"
@@ -10,11 +10,11 @@ import (
10
cmds "github.com/jbenet/go-ipfs/commands"
11
cmdsHttp "github.com/jbenet/go-ipfs/commands/http"
12
"github.com/jbenet/go-ipfs/core"
13
+ commands "github.com/jbenet/go-ipfs/core/commands2"
14
daemon "github.com/jbenet/go-ipfs/daemon2"
15
)
16
17
var daemonCmd = &cmds.Command{
17
- Private: true,
18
Options: []cmds.Option{},
19
Help: "TODO",
20
Subcommands: map[string]*cmds.Command{},
@@ -50,7 +50,7 @@ func daemonFunc(res cmds.Response, req cmds.Request) {
50
return
51
}
52
53
- handler := cmdsHttp.Handler{*ctx, Root}
53
+ handler := cmdsHttp.Handler{*ctx, commands.Root}
54
http.Handle(cmdsHttp.ApiPath+"/", handler)
55
56
fmt.Printf("API server listening on '%s'\n", host)
cmd/ipfs2/init.go
renamed
+1
-2
@@ -1,4 +1,4 @@
1
-package commands
1
+package main
2
3
import (
4
"encoding/base64"
@@ -15,7 +15,6 @@ import (
15
)
16
17
var initCmd = &cmds.Command{
18
- Private: true,
18
Options: []cmds.Option{
19
cmds.Option{[]string{"bits", "b"}, cmds.Int},
20
cmds.Option{[]string{"passphrase", "p"}, cmds.String},
cmd/ipfs2/ipfs.go
new
+15
@@ -0,0 +1,15 @@
1
+package main
2
+
3
+import (
4
+ cmds "github.com/jbenet/go-ipfs/commands"
5
+ commands "github.com/jbenet/go-ipfs/core/commands2"
6
+)
7
+
8
+var Root = &cmds.Command{
9
+ Options: commands.Root.Options,
10
+ Help: commands.Root.Help,
11
+ Subcommands: map[string]*cmds.Command{
12
+ "daemon": daemonCmd,
13
+ "init": initCmd,
14
+ },
15
+}
cmd/ipfs2/main.go
+5
-5
@@ -22,13 +22,13 @@ var log = u.Logger("cmd/ipfs")
22
func main() {
23
args := os.Args[1:]
24
25
- req, err := cmdsCli.Parse(args, commands.Root)
25
+ req, root, err := cmdsCli.Parse(args, Root, commands.Root)
26
if err != nil {
27
fmt.Println(err)
28
os.Exit(1)
29
}
30
31
- options, err := getOptions(req, commands.Root)
31
+ options, err := getOptions(req, root)
32
if err != nil {
33
fmt.Println(err)
34
os.Exit(1)
@@ -80,8 +80,8 @@ func main() {
80
}
81
82
var res cmds.Response
83
- if req.Command().Private {
84
- res = commands.Root.Call(req)
83
+ if root == Root {
84
+ res = root.Call(req)
85
86
} else {
87
local, found := options.Option("local")
@@ -101,7 +101,7 @@ func main() {
101
}
102
ctx.Node = node
103
104
- res = commands.Root.Call(req)
104
+ res = root.Call(req)
105
}
106
}
107
core/commands2/root.go
-2
@@ -56,8 +56,6 @@ var rootSubcommands = map[string]*cmds.Command{
56
"cat": catCmd,
57
"ls": lsCmd,
58
"commands": commandsCmd,
59
- "init": initCmd,
60
- "daemon": daemonCmd,
59
60
// test subcommands
61
// TODO: remove these when we don't need them anymore