提交 d872e0cc 作者: Jeromy

move publish and resolve under the 'name' subcommand

上级 80c64ffa
...@@ -32,7 +32,7 @@ func makeCommand(cmdDesc command) commanderFunc { ...@@ -32,7 +32,7 @@ func makeCommand(cmdDesc command) commanderFunc {
u.POut(c.Long) u.POut(c.Long)
return nil return nil
} }
confdir, err := getConfigDir(c.Parent) confdir, err := getConfigDir(c)
if err != nil { if err != nil {
return err return err
} }
......
...@@ -56,8 +56,7 @@ Use "ipfs help <command>" for more information about a command. ...@@ -56,8 +56,7 @@ Use "ipfs help <command>" for more information about a command.
cmdIpfsInit, cmdIpfsInit,
cmdIpfsServe, cmdIpfsServe,
cmdIpfsRun, cmdIpfsRun,
cmdIpfsPub, cmdIpfsName,
cmdIpfsResolve,
}, },
Flag: *flag.NewFlagSet("ipfs", flag.ExitOnError), Flag: *flag.NewFlagSet("ipfs", flag.ExitOnError),
} }
...@@ -124,7 +123,11 @@ func localNode(confdir string, online bool) (*core.IpfsNode, error) { ...@@ -124,7 +123,11 @@ func localNode(confdir string, online bool) (*core.IpfsNode, error) {
// Gets the config "-c" flag from the command, or returns // Gets the config "-c" flag from the command, or returns
// the default configuration root directory // the default configuration root directory
func getConfigDir(c *commander.Command) (string, error) { func getConfigDir(c *commander.Command) (string, error) {
conf := c.Flag.Lookup("c").Value.Get() root := c
for root.Parent != nil {
root = root.Parent
}
conf := root.Flag.Lookup("c").Value.Get()
if conf == nil { if conf == nil {
return config.PathRoot() return config.PathRoot()
} }
......
package main
import (
"fmt"
flag "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
commander "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
)
var cmdIpfsName = &commander.Command{
UsageLine: "name",
Short: "Ipfs namespace manipulation tools.",
Long: `ipfs name [publish|resolve] <ref/hash>`,
Run: addCmd,
Flag: *flag.NewFlagSet("ipfs-name", flag.ExitOnError),
Subcommands: []*commander.Command{
cmdIpfsPub,
cmdIpfsResolve,
},
}
func nameCmd(c *commander.Command, args []string) error {
fmt.Println(c.Long)
return nil
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论