Commit 29b6e778 authored by Łukasz Magiera's avatar Łukasz Magiera

Move stdin name handling here

parent e0e3b857
......@@ -78,6 +78,11 @@ func isRecursive(req *cmds.Request) bool {
return rec && ok
}
func stdinName(req *cmds.Request) string {
name, _ := req.Options[cmds.StdinName].(string)
return name
}
type parseState struct {
cmdline []string
i int
......@@ -264,7 +269,7 @@ func parseArgs(req *cmds.Request, root *cmds.Command, stdin *os.File) error {
return err
}
fpath = ""
fpath = stdinName(req)
file, err = files.NewReaderPathFile(stdin.Name(), r, nil)
if err != nil {
return err
......@@ -305,7 +310,7 @@ func parseArgs(req *cmds.Request, root *cmds.Command, stdin *os.File) error {
return err
}
fileArgs[""], err = files.NewReaderPathFile(stdin.Name(), r, nil)
fileArgs[stdinName(req)], err = files.NewReaderPathFile(stdin.Name(), r, nil)
if err != nil {
return err
}
......
......@@ -15,6 +15,7 @@ const (
OptShortHelp = "h"
OptLongHelp = "help"
DerefLong = "dereference-args"
StdinName = "stdin-name"
)
// options that are used by this package
......@@ -23,3 +24,4 @@ var OptionRecursivePath = cmdkit.BoolOption(RecLong, RecShort, "Add directory pa
var OptionStreamChannels = cmdkit.BoolOption(ChanOpt, "Stream channel output")
var OptionTimeout = cmdkit.StringOption(TimeoutOpt, "Set a global timeout on the command")
var OptionDerefArgs = cmdkit.BoolOption(DerefLong, "Symlinks supplied in arguments are dereferenced")
var OptionStdinName = cmdkit.StringOption(StdinName, "Assign a name if the file source is stdin.")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment