diff options
| author | Alex Flint <[email protected]> | 2021-08-20 19:52:48 -0700 |
|---|---|---|
| committer | Alex Flint <[email protected]> | 2021-08-20 19:52:48 -0700 |
| commit | 3d59e5e89e775b1d33a451aca6aa4bda4fbad500 (patch) | |
| tree | 71788f3ee1badc138e0f243e15257cf9d2e7c663 /example_test.go | |
| parent | eb0393e9bc0bbd8d3cc37a6ee98c1d538e4e5c91 (diff) | |
bump go-scalar to v1.1 and add documentation about supported types
Diffstat (limited to 'example_test.go')
| -rw-r--r-- | example_test.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/example_test.go b/example_test.go index 2e9b875..8394289 100644 --- a/example_test.go +++ b/example_test.go @@ -2,8 +2,12 @@ package arg import ( "fmt" + "net" + "net/mail" + "net/url" "os" "strings" + "time" ) func split(s string) []string { @@ -377,3 +381,34 @@ func Example_subcommand() { // output: // commit requested with message "what-this-commit-is-about" } + +func Example_allSupportedTypes() { + // These are the args you would pass in on the command line + os.Args = []string{} + + var args struct { + Bool bool + Byte byte + Rune rune + Int int + Int8 int8 + Int16 int16 + Int32 int32 + Int64 int64 + Float32 float32 + Float64 float64 + String string + Duration time.Duration + URL url.URL + Email mail.Address + MAC net.HardwareAddr + } + + // go-arg supports each of the types above, as well as pointers to any of + // the above and slices of any of the above. It also supports any types that + // implements encoding.TextUnmarshaler. + + MustParse(&args) + + // output: +} |
