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
38beda28
Commit
38beda28
authored
Nov 02, 2014
by
Matt Bell
Committed by
Juan Batiz-Benet
Nov 04, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands/cli: Made parser handle variadic arguments
parent
51192582
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
cli/parse.go
cli/parse.go
+8
-8
No files found.
cli/parse.go
View file @
38beda28
...
...
@@ -108,19 +108,19 @@ func parseOptions(input []string) (map[string]interface{}, []string, error) {
// Note that the argument handling here is dumb, it does not do any error-checking.
// (Arguments are further processed when the request is passed to the command to run)
func
parseArgs
(
stringArgs
[]
string
,
cmd
*
cmds
.
Command
)
([]
interface
{},
error
)
{
args
:=
make
([]
interface
{},
len
(
cmd
.
Arguments
))
var
argDef
cmds
.
Argument
args
:=
make
([]
interface
{},
len
(
stringArgs
))
for
i
,
arg
:=
range
cmd
.
Arguments
{
// TODO: handle variadic args
if
i
>=
len
(
stringArgs
)
{
break
for
i
,
arg
:=
range
stringArgs
{
if
i
<
len
(
cmd
.
Arguments
)
{
argDef
=
cmd
.
Arguments
[
i
]
}
if
arg
.
Type
==
cmds
.
ArgString
{
args
[
i
]
=
stringArgs
[
i
]
if
arg
Def
.
Type
==
cmds
.
ArgString
{
args
[
i
]
=
arg
}
else
{
in
,
err
:=
os
.
Open
(
stringArgs
[
i
]
)
in
,
err
:=
os
.
Open
(
arg
)
if
err
!=
nil
{
return
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