expand path names for add command, and pass errors up even more
Jeromy committed
Sep 13, 2014 at 04:42 UTC
35a87e9d0757524042568b8e4976f22fc16d4dfd
4 files changed
+21
-13
cmd/ipfs/add.go
+1
-4
@@ -51,10 +51,7 @@ func addCmd(c *commander.Command, inp []string) error {
51
return err
52
}
53
54
- err = commands.Add(n, cmd.Args, cmd.Opts, os.Stdout)
55
- if err != nil {
56
- fmt.Println(err)
57
- }
54
+ return commands.Add(n, cmd.Args, cmd.Opts, os.Stdout)
55
}
56
return nil
57
}
cmd/ipfs/cat.go
+6
-5
@@ -1,7 +1,6 @@
1
package main
2
3
import (
4
- "fmt"
4
"os"
5
6
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
@@ -29,6 +28,11 @@ func catCmd(c *commander.Command, inp []string) error {
28
return nil
29
}
30
31
+ expanded, err := u.ExpandPathnames(inp)
32
+ if err != nil {
33
+ return err
34
+ }
35
+
36
com := daemon.NewCommand()
37
com.Command = "cat"
38
com.Args = inp
@@ -40,10 +44,7 @@ func catCmd(c *commander.Command, inp []string) error {
44
return err
45
}
46
43
- err = commands.Cat(n, com.Args, com.Opts, os.Stdout)
44
- if err != nil {
45
- fmt.Println(err)
46
- }
47
+ return commands.Cat(n, com.Args, com.Opts, os.Stdout)
48
}
49
return nil
50
}
cmd/ipfs/ls.go
+1
-4
@@ -43,10 +43,7 @@ func lsCmd(c *commander.Command, inp []string) error {
43
return err
44
}
45
46
- err = commands.Ls(n, com.Args, com.Opts, os.Stdout)
47
- if err != nil {
48
- fmt.Println(err)
49
- }
46
+ return commands.Ls(n, com.Args, com.Opts, os.Stdout)
47
}
48
49
return nil
util/util.go
+13
@@ -5,6 +5,7 @@ import (
5
"fmt"
6
"os"
7
"os/user"
8
+ "path/filepath"
9
"strings"
10
11
b58 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
@@ -78,3 +79,15 @@ func DOut(format string, a ...interface{}) {
79
POut(format, a...)
80
}
81
}
82
+
83
+func ExpandPathnames(paths []string) ([]string, error) {
84
+ var out []string
85
+ for _, p := range paths {
86
+ abspath, err := filepath.Abs(p)
87
+ if err != nil {
88
+ return nil, err
89
+ }
90
+ out = append(out, abspath)
91
+ }
92
+ return out, nil
93
+}