summaryrefslogtreecommitdiff
path: root/parse.go
diff options
context:
space:
mode:
Diffstat (limited to 'parse.go')
-rw-r--r--parse.go22
1 files changed, 20 insertions, 2 deletions
diff --git a/parse.go b/parse.go
index 8ef1400..e11c336 100644
--- a/parse.go
+++ b/parse.go
@@ -11,7 +11,7 @@ import (
"reflect"
"strings"
- scalar "github.com/alexflint/go-scalar"
+ "go.wit.com/dev/alexflint/scalar"
)
// path represents a sequence of steps to find the output location for an
@@ -80,11 +80,29 @@ var ErrVersion = errors.New("version requested by user")
var mustParseExit = os.Exit
var mustParseOut io.Writer = os.Stdout
+// This stores the args sent from modules
+var register []interface{}
+
+/*
+ Use this in your packages to register
+ variables with go-arg. Then add this to your init()
+
+ package 'foo'
+ function init() {
+ args.Register(&argsFoo)
+ }
+*/
+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...)
+ register = append(register, dest...)
+ return mustParse(Config{Exit: mustParseExit, Out: mustParseOut}, register...)
}
+
// mustParse is a helper that facilitates testing
func mustParse(config Config, dest ...interface{}) *Parser {
p, err := NewParser(config, dest...)