Commit Graph

305 Commits

Author SHA1 Message Date
Kenneth Shaw d4c2b35b2e Adding separate tag option
As outlined in #49, there is a need to mimic the behavior of other
applications by interweaving positional and non-positional parameters.

This change adds the 'separate' option that will force a arg of type
[]string to only read the next supplied value.

For example, when dealing with the following arg type:

var MyArgs struct {
    Pos []string `arg:"positional"`
    Separate []string `arg:"-s,separate"`
}

This commit will parse the following command line:

./app pos1 pos2 -s=separate1 -s=separate2 pos3 -s=separate3 pos4

Such that MyArgs.Pos will be [pos1 pos2 pos3 pos4] and MyArgs.Separate
will be [separate1 separate2 separate3].

Unit tests for the above have also been written and are included in this
commit, as well as the addition of a section to README.md and an example
func in example_test.go.

Fixes #49
2017-03-04 09:13:12 +07:00
Alex Flint 8488cf10ce Merge pull request #48 from alexflint/parse_hyphen
deal with "-" as option value
2017-02-22 08:38:08 -08:00
Alex Flint c4c162448c deal with "-" as option value 2017-02-21 09:08:08 -08:00
Alex Flint 2c249ee1fc Merge pull request #46 from alexflint/vendoring
vendor in dependencies
2017-02-17 20:57:21 -08:00
Alex Flint 44a8b85d82 deal with booleans correctly 2017-02-15 18:37:19 -08:00
Alex Flint 38c51f4cab put comment back 2017-02-15 18:24:32 -08:00
Alex Flint 6859799559 use go-scalar, vendoring 2017-02-15 18:19:41 -08:00
Alex Flint 765ccf7459 Merge pull request #45 from alexflint/empty_args
Do not crash when os.Args is empty
2017-02-09 19:34:18 -08:00
Alex Flint ec576f9765 fix case where os.Args is empty 2017-02-09 15:12:33 -08:00
Alex Flint b658405f70 Merge pull request #43 from mnsmar/master
print description in help message, not in usage
2017-02-09 10:16:44 -08:00
Emmanouil "Manolis" Maragkakis 9030aa1348 print description in help message, not in usage 2017-02-08 11:41:07 -05:00
Alex Flint bf73829f30 Merge pull request #41 from mnsmar/master
add support for description string
2017-01-24 08:29:43 -08:00
Emmanouil "Manolis" Maragkakis db27431153 add support for description string 2017-01-23 20:41:12 -05:00
Alex Flint 7c77c70f85 Merge pull request #39 from alexflint/embedded
add support for embedded structs
2016-10-11 09:09:17 +10:30
Alex Flint 03900620e2 add not on embedding to readme 2016-10-10 10:52:42 +10:30
Alex Flint 12fa37d10d add support for embedded structs 2016-10-10 10:48:28 +10:30
Alex Flint e6fdb157e9 Merge pull request #38 from alexflint/version_string
Add support for version strings
2016-09-13 18:47:19 -07:00
Alex Flint f882700b72 add to readme 2016-09-08 21:26:12 -07:00
Alex Flint c453aa1a28 add support for version string 2016-09-08 21:18:19 -07:00
Alex Flint 34954f45ce Merge pull request #36 from alexflint/add_goreportcard_readme
Add goreportcard to README.md
2016-07-31 10:18:40 -07:00
Alex Flint 6e9648cac6 add goreportcard to readme.md 2016-07-31 10:16:17 -07:00
Alex Flint a5617823b0 Merge pull request #35 from alexflint/fix_example_names
fix example function names
2016-07-31 09:21:49 -07:00
Alex Flint 5800b89ce9 fix example function names 2016-07-31 09:14:44 -07:00
Alex Flint 34b52501bd Merge pull request #34 from walle/defaults_for_multiple
Print defaults for multiples
2016-03-06 12:44:34 -08:00
Fredrik Wallgren e71d6514f4
Print defaults for multiples
Check if the default value supplied is a slice and not nil, if so
print the list of values supplied.
Test case for slice argument with and without default values.
Default values for slices was not printed because slice is not
comparable, but the zero value for slices is nil.
2016-03-06 21:07:01 +01:00
Alex Flint 45474a9b25 Merge pull request #33 from walle/multiple
Defaults for multiples, intended behaviour
2016-03-04 09:35:36 -08:00
Fredrik Wallgren 1488562b1e
Allow override of defaults for slice arguments
This commit fixes a bug where if a multiple value argument (slice) has default
values, the submitted values will be appended to the default. Not
overriding them as expected.
2016-02-29 22:05:26 +01:00
Alex Flint aaae1550b7 Merge pull request #32 from alexflint/override_program_name
make it possible to override the name of the program
2016-02-22 06:39:41 -08:00
Alex Flint 77dd0df006 Merge pull request #31 from alexflint/parse_ip_mac_and_email
Parse IP addresses, MAC addresses, and email addresses
2016-01-23 21:07:42 -08:00
Alex Flint a1c72f6aa9 Merge remote-tracking branch 'origin/master' into parse_ip_mac_and_email 2016-01-23 21:03:51 -08:00
Alex Flint c0809e537f Merge pull request #30 from alexflint/scalar_pointers
add support for pointers and TextUnmarshaler
2016-01-23 21:03:39 -08:00
Alex Flint c9584269b9 added tests for MAC and email addresses 2016-01-23 20:58:43 -08:00
Alex Flint 9a30acda05 added tests for IP address parsing 2016-01-23 20:55:40 -08:00
Alex Flint e389d7f782 add support for IP address, email address, and MAC address 2016-01-23 20:49:57 -08:00
Alex Flint 8fee8f7bbe move installation instructions to top 2016-01-23 20:11:51 -08:00
Alex Flint 95761fa14a update readme with new additions 2016-01-23 20:08:00 -08:00
Alex Flint b5933a0ea8 Merge remote-tracking branch 'origin/master' into scalar_pointers 2016-01-23 19:42:36 -08:00
Alex Flint 93247e2f3b Merge pull request #29 from alexflint/parse_duration
Add support for time.Duration fields
2016-01-23 19:42:21 -08:00
Alex Flint 865cc5a973 add support for pointers and TextUnmarshaler 2016-01-23 19:40:15 -08:00
Alex Flint 64a4bab550 add test for invalid durations 2016-01-23 18:35:08 -08:00
Alex Flint ed2b19f2bb add support for time.Duration fields 2016-01-23 18:28:35 -08:00
Alex Flint e560d079ba Merge pull request #9 from brettlangdon/dev/environment.variables.sqwished
Add support for environment variables
2016-01-18 11:37:38 -08:00
brettlangdon 8dd29d34bf Add support for environment variables 2016-01-18 13:42:04 -05:00
Alex Flint b1ec8c9093 make it possible to override the name of the program 2016-01-18 10:31:01 -08:00
Alex Flint c9155bb0c3 Merge pull request #26 from alexflint/brettlangdon-dev/positional.help.sqwished
Resolve some merge conflicts from #8
2016-01-18 08:58:11 -08:00
Alex Flint 4197d283e4 extract common colWidth constant 2016-01-18 08:24:21 -08:00
Alex Flint 77be03b907 resolve merge 2016-01-18 08:19:10 -08:00
Alex Flint f8ea16beee Merge pull request #25 from alexflint/return_parser_from_mustparse
MustParse returns *Parser
2016-01-05 16:52:13 -08:00
Alex Flint 9aad09fe14 fix example code 2016-01-05 14:00:29 -08:00
Alex Flint f89698667c add custom validation example to README 2016-01-05 13:57:01 -08:00