Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add link traversal option #96

Merged
merged 1 commit into from
Dec 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions cli/parse.go
Original file line number Diff line number Diff line change
@@ -10,10 +10,9 @@ import (
"sort"
"strings"

"github.com/ipfs/go-ipfs-cmds"

osh "github.com/Kubuxu/go-os-helper"
"github.com/ipfs/go-ipfs-cmdkit"
"github.com/ipfs/go-ipfs-cmds"
"github.com/ipfs/go-ipfs-files"
logging "github.com/ipfs/go-log"
)
@@ -265,6 +264,12 @@ func parseArgs(req *cmds.Request, root *cmds.Command, stdin *os.File) error {
fpath = stdin.Name()
file = files.NewReaderFile("", fpath, r, nil)
} else {
if derefArgs, _ := req.Options[cmds.DerefLong].(bool); derefArgs {
var err error // don't shadow fpath
if fpath, err = filepath.EvalSymlinks(fpath); err != nil {
return err
}
}
nf, err := appendFile(fpath, argDef, isRecursive(req), isHidden(req))
if err != nil {
return err
6 changes: 4 additions & 2 deletions opts.go
Original file line number Diff line number Diff line change
@@ -14,10 +14,12 @@ const (
TimeoutOpt = "timeout"
OptShortHelp = "h"
OptLongHelp = "help"
DerefLong = "dereference-args"
)

// options that are used by this package
var OptionEncodingType = cmdkit.StringOption(EncLong, EncShort, "The encoding type the output should be encoded with (json, xml, or text)").WithDefault("text")
var OptionRecursivePath = cmdkit.BoolOption(RecLong, RecShort, "Add directory paths recursively").WithDefault(false)
var OptionRecursivePath = cmdkit.BoolOption(RecLong, RecShort, "Add directory paths recursively")
var OptionStreamChannels = cmdkit.BoolOption(ChanOpt, "Stream channel output")
var OptionTimeout = cmdkit.StringOption(TimeoutOpt, "set a global timeout on the command")
var OptionTimeout = cmdkit.StringOption(TimeoutOpt, "Set a global timeout on the command")
var OptionDerefArgs = cmdkit.BoolOption(DerefLong, "Symlinks supplied in arguments are dereferenced")