mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-22 04:09:04 +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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = commands.Add(n, cmd.Args, cmd.Opts, os.Stdout)
|
return commands.Add(n, cmd.Args, cmd.Opts, os.Stdout)
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
|
"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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expanded, err := u.ExpandPathnames(inp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
com := daemon.NewCommand()
|
com := daemon.NewCommand()
|
||||||
com.Command = "cat"
|
com.Command = "cat"
|
||||||
com.Args = inp
|
com.Args = inp
|
||||||
@ -40,10 +44,7 @@ func catCmd(c *commander.Command, inp []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = commands.Cat(n, com.Args, com.Opts, os.Stdout)
|
return commands.Cat(n, com.Args, com.Opts, os.Stdout)
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -43,10 +43,7 @@ func lsCmd(c *commander.Command, inp []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = commands.Ls(n, com.Args, com.Opts, os.Stdout)
|
return commands.Ls(n, com.Args, com.Opts, os.Stdout)
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
13
util/util.go
13
util/util.go
@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
b58 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
|
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...)
|
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