ecd369e622
* 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.
17 lines
308 B
Go
17 lines
308 B
Go
package kong
|
|
|
|
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...)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
cmd, err := parser.Parse(os.Args[1:])
|
|
parser.FatalIfErrorf(err)
|
|
return cmd
|
|
}
|