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
ad63af7f
Commit
ad63af7f
authored
Nov 18, 2014
by
Matt Bell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands/cli: Allow option blobs before command path
parent
63656bf3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
cli/parse.go
cli/parse.go
+8
-6
No files found.
cli/parse.go
View file @
ad63af7f
...
...
@@ -71,23 +71,25 @@ func Parse(input []string, stdin *os.File, root *cmds.Command) (cmds.Request, *c
// returns command path slice, rest slice, and the corresponding *cmd.Command
func
parsePath
(
input
[]
string
,
root
*
cmds
.
Command
)
([]
string
,
[]
string
,
*
cmds
.
Command
)
{
cmd
:=
root
i
:=
0
path
:=
make
([]
string
,
0
,
len
(
input
))
input2
:=
make
([]
string
,
0
,
len
(
input
))
for
_
,
blob
:=
range
input
{
for
i
,
blob
:=
range
input
{
if
strings
.
HasPrefix
(
blob
,
"-"
)
{
break
input2
=
append
(
input2
,
blob
)
continue
}
sub
:=
cmd
.
Subcommand
(
blob
)
if
sub
==
nil
{
input2
=
append
(
input2
,
input
[
i
:
]
...
)
break
}
cmd
=
sub
i
++
path
=
append
(
path
,
blob
)
}
return
input
[
:
i
]
,
input
[
i
:
]
,
cmd
return
path
,
input
2
,
cmd
}
// parseOptions parses the raw string values of the given options
...
...
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