Alec Thomas
88ecc9c4e9
Fix enum's from envars not validating ( fixes #107 ).
...
Also added a mapper for `*os.File`.
2020-09-08 13:46:23 +10:00
Alec Thomas
d480572d75
Make counter flags more flexible.
...
They now support three forms:
-s
--long
--long=N
The last of which explicitly sets the counter value.
Fixes #87 .
2020-06-10 15:40:22 +10:00
Cam Hutchison
b89354adb0
Fix sep:"none" and mapsep:"none"
...
According to the README.md, a value of `"none"` for the `sep` tag (for
slices) and `mapsep` (for maps) is meant to disable the separator that
would allow multiple entries to be added from a single argument.
However, using `"none"` just set the separator to the rune `'n'`.
Fix the parsing of the tag, and also update `SplitEscaped` to not split
with a separator of `-1`.
Add a new test for the new cases.
2020-06-02 17:19:11 +10:00
Alec Thomas
2d809c073b
Fix integer overlows in tests on 32-bit systems.
...
Fixes #77 .
2020-04-30 19:48:20 +10:00
Alec Thomas
b6ff115b3e
Correctly parse all numeric types.
...
Fixes #76 .
2020-04-29 09:09:28 +10:00
Alec Thomas
c45ea59559
Add type:"counter".
...
Useful for eg. "-vvv" incrementing verbosity.
Fixes #65 .
2020-03-01 14:35:56 +11:00
Rene Zbinden
529703d8d1
add support to make map separator configurable
2020-02-14 21:25:58 +11:00
Alec Thomas
b4ae5fb86e
Correctly support encoding.{TextUnmarshaler,BinaryUnmarsheler}
2020-02-01 18:21:06 +11:00
Alec Thomas
01b720cb19
Test and docs for TextUnmarshaler and json.Unmarshaler.
2020-01-10 12:15:54 +11:00
Alec Thomas
1076f5ee1f
Remove unused return value from PopValueInto.
2019-06-21 10:07:24 +10:00
Alec Thomas
439c674f7a
Use interface{} instead of string in tokens.
...
This allows the scanner and resolvers to pass Go types around rather
than having to serialise/deserialise to/from strings.
2019-04-24 23:25:13 +10:00
Alec Thomas
e474873f84
Don't show ... in help for named slice types.
2018-11-06 11:15:35 +11:00
Alec Thomas
c0df056b14
Simplify FileContentFlag.
2018-10-25 12:53:55 -07:00
Alec Thomas
0f67a38060
Make FileContentFlag a struct to keep track of the path.
2018-09-22 17:09:28 +10:00
Alec Thomas
1048bd0448
Add a FileContentFlag that loads the contents of a file into a flag
...
value.
2018-09-22 11:14:14 +10:00
Alec Thomas
856d62e28a
Support multiple key+value pairs for map flags.
2018-07-26 20:35:20 +10:00
Alec Thomas
b2cab08684
Add support for a mapper interface directly on fields.
...
If a field implements the MapperValue interface that interface will be
used.
2018-06-29 12:33:50 +10:00
Alec Thomas
00847157a1
Ensure -- consumes all tokens, not just positional.
2018-06-23 08:13:34 +10:00
Alec Thomas
a2ec050947
Implement a robust Context.Run().
...
This helps when composing large applications from separate command
structs.
2018-06-21 21:50:30 +10:00
Alec Thomas
e4f37b5d1a
Support url.URL.
2018-06-21 16:47:53 +10:00
Alec Thomas
212ea2a356
Add path, existingfile and existingdir types.
...
- Document custom types.
- Add docker example.
2018-06-21 16:19:08 +10:00
Alec Thomas
e9d88d6528
Implement flag "resolvers". ( #24 )
...
* Propagate errors.
* Use junit test output.
* Expand role of DecodeContext to include Scanner.
* Inject resolved flags as Path elements in the Context.
This allows all existing logic to apply seamlessly: hooks, required
flags, etc.
* Clarify that hooks can be called multiple times.
2018-06-12 07:20:55 +10:00
Alec Thomas
96fa9c43d5
Improved documentation and help.
2018-06-05 11:36:51 +10:00
Alec Thomas
48af58cefa
Decoders are now field mappers.
...
Mappers are responsible for mapping from command-line input to Go. This
is typically just decoding, but also includes other information such as
if the field is a bool.
2018-06-04 13:13:09 +10:00