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
75b5d275
Commit
75b5d275
authored
Nov 17, 2014
by
Matt Bell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands/cli: Fixed stdin arg handling
parent
0961480a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
cli/parse.go
cli/parse.go
+6
-6
No files found.
cli/parse.go
View file @
75b5d275
...
...
@@ -167,7 +167,7 @@ func parseArgs(inputs []string, stdin *os.File, argDefs []cmds.Argument, recursi
fileArgs
:=
make
([]
cmds
.
File
,
0
,
numInputs
)
argDefIndex
:=
0
// the index of the current argument definition
for
i
,
input
:=
range
inputs
{
for
i
:=
0
;
i
<
numInputs
;
i
++
{
// get the argument definiton (should be argDefs[argDefIndex],
// but if argDefIndex > len(argDefs) we use the last argument definition)
var
argDef
cmds
.
Argument
...
...
@@ -187,7 +187,7 @@ func parseArgs(inputs []string, stdin *os.File, argDefs []cmds.Argument, recursi
if
argDef
.
Type
==
cmds
.
ArgString
{
if
stdin
==
nil
{
// add string values
stringArgs
=
append
(
stringArgs
,
input
)
stringArgs
=
append
(
stringArgs
,
input
s
[
0
]
)
inputs
=
inputs
[
1
:
]
}
else
if
argDef
.
SupportsStdin
{
...
...
@@ -204,7 +204,7 @@ func parseArgs(inputs []string, stdin *os.File, argDefs []cmds.Argument, recursi
}
else
if
argDef
.
Type
==
cmds
.
ArgFile
{
if
stdin
==
nil
{
// treat stringArg values as file paths
path
:=
input
path
:=
input
s
[
0
]
inputs
=
inputs
[
1
:
]
file
,
err
:=
os
.
Open
(
path
)
...
...
@@ -220,17 +220,17 @@ func parseArgs(inputs []string, stdin *os.File, argDefs []cmds.Argument, recursi
if
stat
.
IsDir
()
{
if
!
argDef
.
Recursive
{
err
=
fmt
.
Errorf
(
"Invalid path '%s', argument '%s' does not support directories"
,
input
,
argDef
.
Name
)
path
,
argDef
.
Name
)
return
nil
,
nil
,
err
}
if
!
recursive
{
err
=
fmt
.
Errorf
(
"'%s' is a directory, use the '-%s' flag to specify directories"
,
input
,
cmds
.
RecShort
)
path
,
cmds
.
RecShort
)
return
nil
,
nil
,
err
}
}
fileArg
,
err
:=
getFile
(
file
,
input
)
fileArg
,
err
:=
getFile
(
file
,
path
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
...
...
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