summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile10
-rw-r--r--go.mod15
-rw-r--r--go.sum18
-rw-r--r--parse.go22
-rw-r--r--reflect.go2
-rw-r--r--sequence.go2
-rw-r--r--test/Makefile10
-rw-r--r--test/example_test.go (renamed from example_test.go)0
-rw-r--r--test/go.mod11
-rw-r--r--test/go.sum10
-rw-r--r--test/parse_test.go (renamed from parse_test.go)0
-rw-r--r--test/reflect_test.go (renamed from reflect_test.go)0
-rw-r--r--test/sequence_test.go (renamed from sequence_test.go)0
-rw-r--r--test/subcommand_test.go (renamed from subcommand_test.go)0
-rw-r--r--test/usage_test.go (renamed from usage_test.go)0
15 files changed, 68 insertions, 32 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..7231daa
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,10 @@
+all:
+ @echo
+ @echo
+
+test:
+
+redomod:
+ rm -f go.*
+ GO111MODULE= go mod init
+ GO111MODULE= go mod tidy
diff --git a/go.mod b/go.mod
index ca240d6..be12587 100644
--- a/go.mod
+++ b/go.mod
@@ -1,14 +1,5 @@
-module github.com/alexflint/go-arg
+module go.wit.com/dev/alexflint/arg
-require (
- github.com/alexflint/go-scalar v1.2.0
- github.com/stretchr/testify v1.7.0
-)
+go 1.21.4
-require (
- github.com/davecgh/go-spew v1.1.1 // indirect
- github.com/pmezard/go-difflib v1.0.0 // indirect
- gopkg.in/yaml.v3 v3.0.0 // indirect
-)
-
-go 1.18
+require go.wit.com/dev/alexflint/scalar v1.2.1
diff --git a/go.sum b/go.sum
index e2a4cf1..a867b94 100644
--- a/go.sum
+++ b/go.sum
@@ -1,16 +1,2 @@
-github.com/alexflint/go-scalar v1.2.0 h1:WR7JPKkeNpnYIOfHRa7ivM21aWAdHD0gEWHCx+WQBRw=
-github.com/alexflint/go-scalar v1.2.0/go.mod h1:LoFvNMqS1CPrMVltza4LvnGKhaSpc3oyLEBUZVhhS2o=
-github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
-github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
-github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
-github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
-github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
-gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA=
-gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+go.wit.com/dev/alexflint/scalar v1.2.1 h1:loXOcbVnd+8YeJRLey+XXidecBiedMDO00zQ26TvKNs=
+go.wit.com/dev/alexflint/scalar v1.2.1/go.mod h1:+rYsfxqdI2cwA8kJ7GCMwWbNJvfvWUurOCXLiwdTtSs=
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...)
diff --git a/reflect.go b/reflect.go
index 5d6acb3..a4efe65 100644
--- a/reflect.go
+++ b/reflect.go
@@ -7,7 +7,7 @@ import (
"unicode"
"unicode/utf8"
- scalar "github.com/alexflint/go-scalar"
+ "go.wit.com/dev/alexflint/scalar"
)
var textUnmarshalerType = reflect.TypeOf([]encoding.TextUnmarshaler{}).Elem()
diff --git a/sequence.go b/sequence.go
index 35a3614..e60d2a2 100644
--- a/sequence.go
+++ b/sequence.go
@@ -5,7 +5,7 @@ import (
"reflect"
"strings"
- scalar "github.com/alexflint/go-scalar"
+ "go.wit.com/dev/alexflint/scalar"
)
// setSliceOrMap parses a sequence of strings into a slice or map. If clear is
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 0000000..7231daa
--- /dev/null
+++ b/test/Makefile
@@ -0,0 +1,10 @@
+all:
+ @echo
+ @echo
+
+test:
+
+redomod:
+ rm -f go.*
+ GO111MODULE= go mod init
+ GO111MODULE= go mod tidy
diff --git a/example_test.go b/test/example_test.go
index 9b72b90..9b72b90 100644
--- a/example_test.go
+++ b/test/example_test.go
diff --git a/test/go.mod b/test/go.mod
new file mode 100644
index 0000000..5c6cfd2
--- /dev/null
+++ b/test/go.mod
@@ -0,0 +1,11 @@
+module go.wit.com/dev/alexflint/arg/test
+
+go 1.21.4
+
+require github.com/stretchr/testify v1.8.4
+
+require (
+ github.com/davecgh/go-spew v1.1.1 // indirect
+ github.com/pmezard/go-difflib v1.0.0 // indirect
+ gopkg.in/yaml.v3 v3.0.1 // indirect
+)
diff --git a/test/go.sum b/test/go.sum
new file mode 100644
index 0000000..fa4b6e6
--- /dev/null
+++ b/test/go.sum
@@ -0,0 +1,10 @@
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
+github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/parse_test.go b/test/parse_test.go
index 249cbf3..249cbf3 100644
--- a/parse_test.go
+++ b/test/parse_test.go
diff --git a/reflect_test.go b/test/reflect_test.go
index 10909b3..10909b3 100644
--- a/reflect_test.go
+++ b/test/reflect_test.go
diff --git a/sequence_test.go b/test/sequence_test.go
index fde3e3a..fde3e3a 100644
--- a/sequence_test.go
+++ b/test/sequence_test.go
diff --git a/subcommand_test.go b/test/subcommand_test.go
index 00efae0..00efae0 100644
--- a/subcommand_test.go
+++ b/test/subcommand_test.go
diff --git a/usage_test.go b/test/usage_test.go
index e276e1a..e276e1a 100644
--- a/usage_test.go
+++ b/test/usage_test.go