Skip to content
Permalink
Browse files
Closes #63
Fixes index out of range issue

Wasn't handling calls where there were only flag params e.g.
br -v
  • Loading branch information
geomacy committed Nov 9, 2017
2 parents d20d912 + ebcd140 commit 18967dfcf92af803d75d51f72ba26491cca5a80a
Showing 2 changed files with 10 additions and 1 deletion.
@@ -100,7 +100,7 @@ func defineScope(args []string, scope *Scope) []string {
// args is: name [global flags] [scope and id pair] command [flags] [arguments]
// Skip name and global flags
idx := 1
for isFlag(args[idx]) {
for idx < len(args) && isFlag(args[idx]) {
idx += 1
}
newArgs := args[:idx]
@@ -59,7 +59,16 @@ func TestScope(t *testing.T) {
Args: []string{"br", "--verbose", "a", "appid", "e", "entityId", "v", "--children", "activityId"},
ExpectedArgs: []string{"br", "--verbose", "v", "--children", "activityId"},
ExpectedScope: Scope{Application: "appid", Entity: "entityId"},
},{
Args: []string{"br", "-v"},
ExpectedArgs: []string{"br", "-v"},
ExpectedScope: Scope{},
},{
Args: []string{"br", "--help", "-v"},
ExpectedArgs: []string{"br", "--help", "-v"},
ExpectedScope: Scope{},
},

}
for _, elem := range testCases {
argsOut, scope := ScopeArguments(elem.Args)

0 comments on commit 18967df

Please sign in to comment.