mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-20 19:19:06 +08:00
expand path names for add command, and pass errors up even more
This commit is contained in:
@ -51,10 +51,7 @@ func addCmd(c *commander.Command, inp []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = commands.Add(n, cmd.Args, cmd.Opts, os.Stdout)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
return commands.Add(n, cmd.Args, cmd.Opts, os.Stdout)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
|
||||
@ -29,6 +28,11 @@ func catCmd(c *commander.Command, inp []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
expanded, err := u.ExpandPathnames(inp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
com := daemon.NewCommand()
|
||||
com.Command = "cat"
|
||||
com.Args = inp
|
||||
@ -40,10 +44,7 @@ func catCmd(c *commander.Command, inp []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = commands.Cat(n, com.Args, com.Opts, os.Stdout)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
return commands.Cat(n, com.Args, com.Opts, os.Stdout)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -43,10 +43,7 @@ func lsCmd(c *commander.Command, inp []string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = commands.Ls(n, com.Args, com.Opts, os.Stdout)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
return commands.Ls(n, com.Args, com.Opts, os.Stdout)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
13
util/util.go
13
util/util.go
@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
b58 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
|
||||
@ -78,3 +79,15 @@ func DOut(format string, a ...interface{}) {
|
||||
POut(format, a...)
|
||||
}
|
||||
}
|
||||
|
||||
func ExpandPathnames(paths []string) ([]string, error) {
|
||||
var out []string
|
||||
for _, p := range paths {
|
||||
abspath, err := filepath.Abs(p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out = append(out, abspath)
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user