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
5f50ea19
Commit
5f50ea19
authored
Oct 21, 2014
by
Matt Bell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands: Do command collision check in GetOptions
parent
031d0847
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
command.go
command.go
+6
-2
No files found.
command.go
View file @
5f50ea19
...
...
@@ -111,13 +111,13 @@ func (c *Command) Get(path []string) (*Command, error) {
// GetOptions gets the options in the given path of commands
func
(
c
*
Command
)
GetOptions
(
path
[]
string
)
(
map
[
string
]
Option
,
error
)
{
options
:=
make
([]
Option
,
len
(
c
.
Options
))
copy
(
options
,
c
.
Options
)
options
=
append
(
options
,
globalOptions
...
)
cmds
,
err
:=
c
.
Resolve
(
path
)
if
err
!=
nil
{
return
nil
,
err
}
cmds
=
append
(
cmds
,
globalCommand
)
for
_
,
cmd
:=
range
cmds
{
options
=
append
(
options
,
cmd
.
Options
...
)
}
...
...
@@ -125,6 +125,10 @@ func (c *Command) GetOptions(path []string) (map[string]Option, error) {
optionsMap
:=
make
(
map
[
string
]
Option
)
for
_
,
opt
:=
range
options
{
for
_
,
name
:=
range
opt
.
Names
{
if
_
,
found
:=
optionsMap
[
name
];
found
{
return
nil
,
fmt
.
Errorf
(
"Option name '%s' used multiple times"
,
name
)
}
optionsMap
[
name
]
=
opt
}
}
...
...
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