move publish and resolve under the 'name' subcommand
Jeromy committed
Oct 2, 2014 at 22:30 UTC
d872e0cce522a35eb3db826a5c184bba781b3b20
3 files changed
+32
-4
cmd/ipfs/gen.go
+1
-1
@@ -32,7 +32,7 @@ func makeCommand(cmdDesc command) commanderFunc {
32
u.POut(c.Long)
33
return nil
34
}
35
- confdir, err := getConfigDir(c.Parent)
35
+ confdir, err := getConfigDir(c)
36
if err != nil {
37
return err
38
}
cmd/ipfs/ipfs.go
+6
-3
@@ -56,8 +56,7 @@ Use "ipfs help <command>" for more information about a command.
56
cmdIpfsInit,
57
cmdIpfsServe,
58
cmdIpfsRun,
59
- cmdIpfsPub,
60
- cmdIpfsResolve,
59
+ cmdIpfsName,
60
},
61
Flag: *flag.NewFlagSet("ipfs", flag.ExitOnError),
62
}
@@ -124,7 +123,11 @@ func localNode(confdir string, online bool) (*core.IpfsNode, error) {
123
// Gets the config "-c" flag from the command, or returns
124
// the default configuration root directory
125
func getConfigDir(c *commander.Command) (string, error) {
127
- conf := c.Flag.Lookup("c").Value.Get()
126
+ root := c
127
+ for root.Parent != nil {
128
+ root = root.Parent
129
+ }
130
+ conf := root.Flag.Lookup("c").Value.Get()
131
if conf == nil {
132
return config.PathRoot()
133
}
cmd/ipfs/name.go
new
+25
@@ -0,0 +1,25 @@
1
+package main
2
+
3
+import (
4
+ "fmt"
5
+
6
+ flag "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
7
+ commander "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
8
+)
9
+
10
+var cmdIpfsName = &commander.Command{
11
+ UsageLine: "name",
12
+ Short: "Ipfs namespace manipulation tools.",
13
+ Long: `ipfs name [publish|resolve] <ref/hash>`,
14
+ Run: addCmd,
15
+ Flag: *flag.NewFlagSet("ipfs-name", flag.ExitOnError),
16
+ Subcommands: []*commander.Command{
17
+ cmdIpfsPub,
18
+ cmdIpfsResolve,
19
+ },
20
+}
21
+
22
+func nameCmd(c *commander.Command, args []string) error {
23
+ fmt.Println(c.Long)
24
+ return nil
25
+}