Commit graph

74 commits

Author SHA1 Message Date
Kevin K
fd8e211895 tests(Subcommand Aliases): adds tests for new aliases 2016-05-10 15:26:43 -04:00
Kevin K
b42ca0b5ab chore(Tests): had to remove external clap-test crate...sad face 2016-05-09 22:46:09 -04:00
Kevin K
417dbc3057 test: adds test for new group deduping 2016-05-09 19:14:11 -04:00
Kevin K
852e58156c tests: removes old python tests and replaces with rust tests
Closes #166
2016-05-09 19:14:11 -04:00
Kevin K
a0a56318d0 tests(Groups): adds tests for positional arg formatting in groups 2016-05-08 21:33:56 -04:00
Kevin K
250ed41f10 tests(Help): changes formatting for positional arguments 2016-05-08 20:38:13 -04:00
Kevin K
9fdad2e970 tests: adds tests for required_unless settings 2016-05-03 16:31:54 -04:00
Hernan Grecco
627ae38dc0 refactor(HELP): Removed code for old help system and tests that helped with the transitions 2016-04-13 07:21:21 -03:00
Hernan Grecco
81e121edd6 feat(HELP): Add a Templated Help system.
The strategy is to copy the template from the the reader to wrapped stream
until a tag is found. Depending on its value, the appropriate content is copied
to the wrapped stream.
The copy from template is then resumed, repeating this sequence until reading
the complete template.

Tags arg given inside curly brackets:
Valid tags are:
    * `{bin}`         - Binary name.
    * `{version}`     - Version number.
    * `{author}`      - Author information.
    * `{usage}`       - Automatically generated or given usage string.
    * `{all-args}`    - Help for all arguments (options, flags, positionals arguments,
                        and subcommands) including titles.
    * `{unified}`     - Unified help for options and flags.
    * `{flags}`       - Help for flags.
    * `{options}`     - Help for options.
    * `{positionals}` - Help for positionals arguments.
    * `{subcommands}` - Help for subcommands.
    * `{after-help}`  - Help for flags.
2016-04-13 07:06:23 -03:00
Hernan Grecco
04b5b074d1 refactor(HELP): A new Help Engine
The largest organizational change is that methods used to generate the help are
implemented by the Help object and not the App, FlagBuilder, Parser, etc.

The new code is based heavily on the old one with a few minor modifications
aimed to reduce code duplication and coupling between the Help and the rest
of the code.

The new code turn things around: instead of having a HelpWriter that holds an
AnyArg object and a method that is called with a writer as argument,
there is a Help Object that holds a writer and a method that is called with a
writer as an argument.

There are still things to do such as moving `create_usage` outside the Parser.

The peformance has been affected, probably by the use of Trait Objects. This
was done as a way to reduce code duplication (i.e. in the unified help code).
This performance hit should not affect the usability as generating and printing
the help is dominated by user interaction and IO.

The old code to generate the help is still functional and is the active one.
The new code has been tested against the old one by generating help strings
for most of the examples in the repo.
2016-04-13 07:06:23 -03:00
Kevin K
c3795ad404 tests(Groups): removes tests causing issues that werent required 2016-04-09 22:33:49 -07:00
Kevin K
0e69314e53 test(Help Message): adds test to prevent issue-472 2016-04-02 20:47:27 -04:00
Kevin K
baf0e18095 tests(Empty Values): adds tests for empty values 2016-03-29 22:31:40 -04:00
Kevin K
991aefc10a tests: updates tests to new verions 2016-03-16 10:22:00 -04:00
Kevin K
675c39f8ba tests: moves app settings tests to the proper place 2016-03-13 22:07:28 -04:00
Kevin K
e428bb6d84 tests: moves some \t tabs to four spaces for consistency 2016-03-13 22:07:28 -04:00
Kevin K
6efa298cba test: fixes failing doc tests 2016-02-19 01:47:37 -05:00
Kevin K
9250b1323c tests: adds tests for default values 2016-02-10 10:56:58 -05:00
Kevin K
26f2e5feb0 tests(Multiple Values): fixes failing benches and adds tests to guard 2016-02-04 22:15:10 -05:00
Kevin K
2ba12b8b76 tests(Multiple Values): adds test for exact number of values 2016-02-04 19:44:30 -05:00
Kevin K
4f207a1195 tests(AppSettings): adds test for GlobalVersion 2016-02-04 11:55:58 -05:00
Kevin K
a33e3df8f5 tests: adds tests for stdin char and only positional vals follow 2016-02-04 02:01:10 -05:00
Alex Hill
85b11468b0 fix: Stop lonely hyphens from causing panic
The method `starts_with` as implemented for the `OsStrExt2` trait on
`OsStr` assumed that the needle given is shorter than the haystack. When
this is not the case, the method panics due to an attempted
out-of-bounds access on the byte representation of `self`. Problematic
if, say, an end-user gives us `"-"` and the library tries to see if that
starts with `"--"`.

Fortunately, slices already implement a `starts_with` method, and we can
delegate to it.

This *does* create a semantics change: if both `self` and the needle
have length 0, this implementation will return `true`, but the old
implementation would return `false`. Based on the test suite still
passing, acknowledging the vacuous truth doesn't seem to cause any
problems.

Fixes #410
2016-02-02 21:05:45 -08:00
Kevin K
07dfdd00ea tests(multiples): adds tests for > u8::max vals and occurrences 2016-02-02 07:45:49 -05:00
Kevin K
7596951a30 tests: adds additional tests for new setting and missing old tests 2016-02-02 07:21:01 -05:00
Ceri Storey
3731ddb361 fix(matched_arg): Allow for more than 256 occurrences of an argument. 2016-02-02 19:30:32 +00:00
Kevin K
4735f4d5cb tests(SubCommands): adds tests for subcmds after mult args 2016-01-31 07:37:20 -05:00
Kevin K
816cec8152 tests(Usage Parser): moves tests usage parser since that's what it's testing 2016-01-31 07:12:15 -05:00
Kevin K
90542747ac chore: fixes doc and style mistakes 2016-01-28 21:58:40 -05:00
Kevin K
474f27af43 tests: adds tests for values when delims have been turned off 2016-01-28 11:45:31 -05:00
Kevin K
7b0ff38fe7 tests: adds tests for different value delimiters 2016-01-28 11:45:31 -05:00
Kevin K
28041cdad9 tests: adds tests for comma separated values 2016-01-28 11:45:31 -05:00
Kevin K
f17e150894 tests(Usage Parser): adds and fixes tests for usage parser 2016-01-28 11:45:31 -05:00
Kevin K
32dd302f97 tests: fixes tests for optional option values 2016-01-28 11:45:31 -05:00
Kevin K
e874a0d5e0 feat(UTF-8): adds support for invalid utf8 in values
Closes #269
2016-01-28 11:45:31 -05:00
Kevin K
c3e96232c9 tests(v2): fixing more tests on the new v2 base 2016-01-28 11:45:31 -05:00
Kevin K
0031d78564 refactor(v2): improving macros for code dedup 2016-01-28 11:45:31 -05:00
Kevin K
7fc18e685f test(v2): fixing tests to pass under new v2 changes 2016-01-28 11:45:31 -05:00
Sung Rim Huh
44cbed1a2a tests(help): add tests for help subcommand 2016-01-14 20:23:50 -08:00
Sung Rim Huh
32ef3264b9 tests: add checks for help and version flag 2016-01-13 09:03:27 -08:00
Sung Rim Huh
1c41d1bf43 tests(possible_values): add tests for possible values 2016-01-13 08:52:42 -08:00
Sung Rim Huh
e2c63cded7 tests(multiple_values): add positional multiple values 2016-01-13 08:28:24 -08:00
Sung Rim Huh
346450e6f1 tests(subcommands): add subcommand tests 2016-01-13 08:06:00 -08:00
Sung Rim Huh
3936b28035 tests(yaml): use scope wide attribute 2016-01-11 21:13:14 -08:00
Sung Rim Huh
b2d29b0a68 tests(unicode): use scope wide attribute 2016-01-11 21:08:38 -08:00
Kevin K
6372b4844f tests(unicode): removes unicode testing from Windows builds 2015-12-18 09:01:59 -05:00
Sung Rim Huh
389d14ab85 tests(multiple_values): move tests related to multiple values 2015-12-10 09:09:50 -08:00
Kevin K
8988853fb8 imp(ArgMatcher): huge refactor and deduplication of code
Tons of code has been moved into functions, deduplicated, made much
easier to read, maintain, and understand. Comments still need to be
added, but that will happen shortly. Modules have also been moved around
to follow Rust conventions and best practices.

All functionality remains exactly the same
2015-11-11 10:26:05 -05:00
Kevin K
ea4740ca3b tests(Errors): improves error testing 2015-11-03 08:26:17 -05:00
Kevin K
aff89d579b feat: allows parsing without a binary name for daemons and interactive CLIs
Closes #318
2015-10-28 06:45:49 -04:00