Kong tag PR fixes (#12)

* Removed bubbling errors in favour of panic
* Added a test for Parse with a bad build and an arg.
* Removed is() function in favour of a switch with strings
* Collect key and value in parseCSV, reducing complexity.
* Fix in global to not use parser instance on error.
This commit is contained in:
Gerald Kaszuba
2018-05-22 23:18:08 +10:00
committed by Alec Thomas
parent 31e1ffaa3b
commit ecd369e622
5 changed files with 80 additions and 59 deletions
+6 -2
View File
@@ -1,11 +1,15 @@
package kong
import "os"
import (
"os"
)
// Parse constructs a new parser and parses the default command-line.
func Parse(cli interface{}, options ...Option) string {
parser, err := New(cli, options...)
parser.FatalIfErrorf(err)
if err != nil {
panic(err)
}
cmd, err := parser.Parse(os.Args[1:])
parser.FatalIfErrorf(err)
return cmd