Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3-cmds
Commits
29b6e778
Commit
29b6e778
authored
Mar 21, 2019
by
Łukasz Magiera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move stdin name handling here
parent
e0e3b857
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
cli/parse.go
cli/parse.go
+7
-2
opts.go
opts.go
+2
-0
No files found.
cli/parse.go
View file @
29b6e778
...
...
@@ -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
}
...
...
opts.go
View file @
29b6e778
...
...
@@ -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."
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment