提交 cac8844b 作者: Matt Bell 提交者: Juan Batiz-Benet

cmd/ipfs: Reverted back to secondary CLI root command

上级 24814a41
package commands package main
import ( import (
"fmt" "fmt"
...@@ -10,11 +10,11 @@ import ( ...@@ -10,11 +10,11 @@ import (
cmds "github.com/jbenet/go-ipfs/commands" cmds "github.com/jbenet/go-ipfs/commands"
cmdsHttp "github.com/jbenet/go-ipfs/commands/http" cmdsHttp "github.com/jbenet/go-ipfs/commands/http"
"github.com/jbenet/go-ipfs/core" "github.com/jbenet/go-ipfs/core"
commands "github.com/jbenet/go-ipfs/core/commands2"
daemon "github.com/jbenet/go-ipfs/daemon2" daemon "github.com/jbenet/go-ipfs/daemon2"
) )
var daemonCmd = &cmds.Command{ var daemonCmd = &cmds.Command{
Private: true,
Options: []cmds.Option{}, Options: []cmds.Option{},
Help: "TODO", Help: "TODO",
Subcommands: map[string]*cmds.Command{}, Subcommands: map[string]*cmds.Command{},
...@@ -50,7 +50,7 @@ func daemonFunc(res cmds.Response, req cmds.Request) { ...@@ -50,7 +50,7 @@ func daemonFunc(res cmds.Response, req cmds.Request) {
return return
} }
handler := cmdsHttp.Handler{*ctx, Root} handler := cmdsHttp.Handler{*ctx, commands.Root}
http.Handle(cmdsHttp.ApiPath+"/", handler) http.Handle(cmdsHttp.ApiPath+"/", handler)
fmt.Printf("API server listening on '%s'\n", host) fmt.Printf("API server listening on '%s'\n", host)
......
package commands package main
import ( import (
"encoding/base64" "encoding/base64"
...@@ -15,7 +15,6 @@ import ( ...@@ -15,7 +15,6 @@ import (
) )
var initCmd = &cmds.Command{ var initCmd = &cmds.Command{
Private: true,
Options: []cmds.Option{ Options: []cmds.Option{
cmds.Option{[]string{"bits", "b"}, cmds.Int}, cmds.Option{[]string{"bits", "b"}, cmds.Int},
cmds.Option{[]string{"passphrase", "p"}, cmds.String}, cmds.Option{[]string{"passphrase", "p"}, cmds.String},
......
package main
import (
cmds "github.com/jbenet/go-ipfs/commands"
commands "github.com/jbenet/go-ipfs/core/commands2"
)
var Root = &cmds.Command{
Options: commands.Root.Options,
Help: commands.Root.Help,
Subcommands: map[string]*cmds.Command{
"daemon": daemonCmd,
"init": initCmd,
},
}
...@@ -22,13 +22,13 @@ var log = u.Logger("cmd/ipfs") ...@@ -22,13 +22,13 @@ var log = u.Logger("cmd/ipfs")
func main() { func main() {
args := os.Args[1:] args := os.Args[1:]
req, err := cmdsCli.Parse(args, commands.Root) req, root, err := cmdsCli.Parse(args, Root, commands.Root)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
os.Exit(1) os.Exit(1)
} }
options, err := getOptions(req, commands.Root) options, err := getOptions(req, root)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
os.Exit(1) os.Exit(1)
...@@ -80,8 +80,8 @@ func main() { ...@@ -80,8 +80,8 @@ func main() {
} }
var res cmds.Response var res cmds.Response
if req.Command().Private { if root == Root {
res = commands.Root.Call(req) res = root.Call(req)
} else { } else {
local, found := options.Option("local") local, found := options.Option("local")
...@@ -101,7 +101,7 @@ func main() { ...@@ -101,7 +101,7 @@ func main() {
} }
ctx.Node = node ctx.Node = node
res = commands.Root.Call(req) res = root.Call(req)
} }
} }
......
...@@ -56,8 +56,6 @@ var rootSubcommands = map[string]*cmds.Command{ ...@@ -56,8 +56,6 @@ var rootSubcommands = map[string]*cmds.Command{
"cat": catCmd, "cat": catCmd,
"ls": lsCmd, "ls": lsCmd,
"commands": commandsCmd, "commands": commandsCmd,
"init": initCmd,
"daemon": daemonCmd,
// test subcommands // test subcommands
// TODO: remove these when we don't need them anymore // TODO: remove these when we don't need them anymore
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论