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
66e6da3d
Commit
66e6da3d
authored
Oct 14, 2014
by
Matt Bell
Committed by
Juan Batiz-Benet
Oct 20, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands/cli: Added value parsing for single-dash options
parent
08885c0c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
+13
-3
commands/cli/parse.go
commands/cli/parse.go
+13
-3
No files found.
commands/cli/parse.go
View file @
66e6da3d
...
...
@@ -46,7 +46,7 @@ func parsePath(input []string, root *commands.Command) ([]string, []string, erro
// options parses the raw string values of the given options
// returns the parsed options as strings, along with the CLI args
func
parseOptions
(
input
,
path
[]
string
,
root
*
commands
.
Command
)
(
map
[
string
]
string
,
[]
string
,
error
)
{
_
,
err
:=
root
.
GetOptions
(
path
)
options
,
err
:=
root
.
GetOptions
(
path
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
...
...
@@ -109,11 +109,21 @@ func parseOptions(input, path []string, root *commands.Command) (map[string]stri
return
nil
,
nil
,
fmt
.
Errorf
(
"Invalid option blob: '%s'"
,
input
[
i
])
}
nameS
:=
""
for
_
,
name
:=
range
blob
{
opts
[
string
(
name
)]
=
""
nameS
=
string
(
name
)
opts
[
nameS
]
=
""
}
// TODO: interpret next blob as value if the last option isn't a bool
if
nameS
!=
""
{
opt
,
ok
:=
options
[
nameS
]
if
ok
&&
opt
.
Type
!=
commands
.
Bool
{
i
++
if
i
<=
len
(
input
)
{
opts
[
nameS
]
=
input
[
i
]
}
}
}
}
else
{
args
=
append
(
args
,
blob
)
...
...
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