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
Commits
aa84f692
Commit
aa84f692
authored
Nov 19, 2014
by
Matt Bell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands: Added a 'Definition()' method to OptionValue to get a reference to the option definiton
parent
bbf3a1f4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
commands/option.go
commands/option.go
+6
-0
commands/request.go
commands/request.go
+2
-2
No files found.
commands/option.go
View file @
aa84f692
...
...
@@ -83,6 +83,7 @@ func StringOption(names ...string) Option {
type
OptionValue
struct
{
value
interface
{}
found
bool
def
Option
}
// Found returns true if the option value was provided by the user (not a default value)
...
...
@@ -90,6 +91,11 @@ func (ov OptionValue) Found() bool {
return
ov
.
found
}
// Definition returns the option definition for the provided value
func
(
ov
OptionValue
)
Definition
()
Option
{
return
ov
.
def
}
// value accessor methods, gets the value as a certain type
func
(
ov
OptionValue
)
Bool
()
(
value
bool
,
found
bool
,
err
error
)
{
if
!
ov
.
found
{
...
...
commands/request.go
View file @
aa84f692
...
...
@@ -102,12 +102,12 @@ func (r *request) Option(name string) *OptionValue {
for
_
,
n
:=
range
option
.
Names
()
{
val
,
found
:=
r
.
options
[
n
]
if
found
{
return
&
OptionValue
{
val
,
found
}
return
&
OptionValue
{
val
,
found
,
option
}
}
}
// MAYBE_TODO: use default value instead of nil
return
&
OptionValue
{
nil
,
false
}
return
&
OptionValue
{
nil
,
false
,
option
}
}
// Options returns a copy of the option map
...
...
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