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
db8a7e28
Commit
db8a7e28
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 path/args parsing
parent
6094743a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
1 deletion
+24
-1
cli/parse.go
cli/parse.go
+24
-1
No files found.
cli/parse.go
View file @
db8a7e28
...
...
@@ -13,7 +13,12 @@ func Parse(input []string, root *commands.Command) ([]string, []string, map[stri
return
nil
,
nil
,
nil
,
err
}
return
nil
,
nil
,
opts
,
nil
path
,
args
,
err
:=
path
(
input
,
root
)
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
err
}
return
path
,
args
,
opts
,
nil
}
// options parses the raw string values of the given options
...
...
@@ -90,3 +95,21 @@ func options(input []string, root *commands.Command) (map[string]string, []strin
return
opts
,
cleanInput
,
nil
}
// path takes the command line (without options) and splits it into the command path and arguments
func
path
(
input
[]
string
,
root
*
commands
.
Command
)
([]
string
,
[]
string
,
error
)
{
cmd
:=
root
i
:=
0
for
_
,
blob
:=
range
input
{
cmd
:=
cmd
.
Sub
(
blob
)
if
cmd
==
nil
{
break
}
i
++
}
return
input
[
:
i
],
input
[
i
:
],
nil
}
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