test against go-args' head

This commit is contained in:
Jeff Carr 2025-08-28 20:59:03 -05:00
parent a36ed1e7b3
commit 5be2559741
1 changed files with 17 additions and 1 deletions

View File

@ -80,9 +80,25 @@ var ErrVersion = errors.New("version requested by user")
var mustParseExit = os.Exit
var mustParseOut io.Writer = os.Stdout
/*
This allows you to have common arg values defined in a GO package
package 'foo'
function init() {
args.Register(&argsFoo)
}
*/
// This stores the args sent from the GO packages
var register []interface{}
func Register(dest ...interface{}) {
register = append(register, dest...)
}
// MustParse processes command line arguments and exits upon failure
func MustParse(dest ...interface{}) *Parser {
return mustParse(Config{Exit: mustParseExit, Out: mustParseOut}, dest...)
return mustParse(Config{Exit: mustParseExit, Out: mustParseOut}, register...)
}
// mustParse is a helper that facilitates testing