Commit graph

615 commits

Author SHA1 Message Date
Kevin K
eb0e374ecf fix(usage strings): positional arguments are presented in index order
Positional arguments are now presented in index order in suggested usage
strings which prevents out of order suggestions.

Closes #112
2015-05-08 11:37:45 -04:00
Kevin K
4903adde61 chore(clap): increase version 2015-05-06 12:47:32 -04:00
Kevin K.
73229bda2c Merge pull request #111 from kbknapp/less-color 2015-05-06 11:43:01 -04:00
Kevin K
a5e25a563c tests(run_tests.py): update to new error messages 2015-05-06 12:36:12 -04:00
Kevin K
fc79017ece fix(subcommands): stops parsing multiple values when subcommands are found
Closes #109
2015-05-06 12:36:03 -04:00
Kevin K
994474146e im(suggestions): adds suggested arguments to usage strings 2015-05-06 12:36:03 -04:00
Kevin K
55f71117c6 refactor(errors): fix error messages 2015-05-06 12:36:03 -04:00
Kevin K
c445a100f9 tests(run_tests.py): uses new error messages 2015-05-06 12:36:03 -04:00
Kevin K
aab44cca63 im(color): reduces color in error messages
Closes #110
2015-05-06 12:35:52 -04:00
Kevin K
05a34c8eec chore(clap): increase version 2015-05-05 22:11:37 -04:00
Kevin K.
0994caaccf Merge pull request #108 from kbknapp/patch-100
Closes #100 and other fixes
2015-05-05 22:10:14 -04:00
Kevin K
8745071c32 feat(Flags): adds sugestions functionality 2015-05-05 22:05:02 -04:00
Kevin K
0eda91a447 chore(.clog.toml): updates clog config 2015-05-05 22:05:02 -04:00
Kevin K
960389de02 docs(README): adds details about optional and new features 2015-05-05 22:05:02 -04:00
Kevin K
90e7b08187 fix(Positional): positionals were ignored if they matched a subcmd, even after '--' 2015-05-05 22:05:02 -04:00
Kevin K
a3e0671336 tests(arg_enum): adds tests 2015-05-05 22:05:02 -04:00
Kevin K
73d5a974eb tests(colors): removes ansi color codes before testing 2015-05-05 22:05:02 -04:00
Kevin K
632fb11514 fix(help): fixes bug where space between arg and help is too long 2015-05-05 22:05:02 -04:00
Kevin K
f8b26b13da feat(errors): colorizes output red on error 2015-05-05 22:05:02 -04:00
Tshepang Lekhonkhobe
8891d92917 docs(clap): fix typos caught by codespell
Thanks to [tshepang](https://github.com/tshepang) for catching these!
2015-05-05 22:02:14 -04:00
Sebastian Thiel
0535cfb0c7 fix(did-you-mean): for review
* unknown subcommand message altered to use similar language as is used
  everywhere around clap. Namely, we say 'invalid' instead of 'unknown'
* 'did-you-mean' message separator changed from '. ' to '\n\t'

Related to #103
2015-05-05 17:12:20 -04:00
Sebastian Thiel
3631de580a refactor(makefile): hide comments
These comments show up on travis, which is not desired

[skip ci]
2015-05-05 17:12:20 -04:00
Sebastian Thiel
d3761a2c20 refactor(run_tests): python 2/3 compatibility
That way, it will run on travis as well, which comes with python 2
by default, and just doesn't have python 3 pre-installed.
It would probably take to much time to install, especially considering
it's super easy to have to script work in both worlds.
2015-05-05 17:12:20 -04:00
Sebastian Thiel
c0e383515d feat(did-you-mean): gate it behind 'suggestions'
You can now disable the did-you-mean feature entirely, which also
removes the additional dependency it comes with.
Learn more about features and how to use them here:
http://doc.crates.io/manifest.html#the-[features]-section

Related to #103
2015-05-05 17:12:20 -04:00
Sebastian Thiel
de7d10af4c tests(travis): added claptests based tests
Run the python based --release mode tests as well. They are mainly
concerned with user facing messages, which are as important as the
internal tests run `cargo test`.
2015-05-05 17:12:20 -04:00
Sebastian Thiel
9707917407 refactor(travis): update to latest version
More about this can be found [here](http://goo.gl/vt07f7).
It's somewhat unnecessary, but I thought it might be good in preparation
for the next commit.
2015-05-05 17:12:20 -04:00
Sebastian Thiel
1cc2deb291 feat(did-you-mean): for possible values
There now is a single method which deals with formatting the
'did-you-mean' message, supporting different styles to cater all the
various needs that have arisen thus far, with enough potential to be
easily extended in future through a little helper-enumeration whose
variants can possibly take values.

*NOTE*: We might still want to have a look at where the did-you-mean
message should be located for best effect.

Related to #103
2015-05-05 17:12:20 -04:00
Sebastian Thiel
627ec103c9 refactor(app):dedup possible_values error-handling
This is done in preparation for adding suggestions.

**NOTE**: We will now always use the ...
`"\"{}\" isn't a valid value for '{}'{}"`
... format, even though in one occasion, only a ...
`"\"{}\" isn't a valid value for {}{}"`
... format was used.

Hope that's alright and not breaking the world. At least, it doesn't
break any of the existing tests.
2015-05-05 17:12:20 -04:00
Sebastian Thiel
94dd9da1c5 tests(main.rs): add long --Option to -O
To facilitate running different branches of code that looks
rather similar.
2015-05-05 17:12:20 -04:00
Sebastian Thiel
5407ac6cd6 refactor(app): better use of type-inference
Removing explicit typing makes the code more readable, which makes it
more maintainable, which probably helps everyone :).
2015-05-05 17:12:20 -04:00
Sebastian Thiel
0dd095f975 refactor(did-you-mean): dedup. thanks to suffix
That way, we use the prefix previously used by clap, but add our
particular 'did-you-mean' phrase as a suffix.
2015-05-05 17:12:20 -04:00
Sebastian Thiel
52a0b8505c feat(did-you-mean): for long flags (i.e. --long)
Long arguments now have a special case when saying they are unknown, as
we will match it against all known long flags and suggest the best match
to be used instead.

TODO: refactor to just write a suffix with did-you-mean information.

Related to #103
2015-05-05 17:12:20 -04:00
Sebastian Thiel
06e869b518 feat(did-you-mean): for subcommands
If an argument is not understood as subcommand, but has a
high-confidence match in the list of all known subcommands, we will use
this one to print a customized error message.

Previously, it would say that a positional argument wasn't understood,
now it will say that a subcommand was unknown, and if the user meant
`high-confidence-candidate`.

If the argument doesn't sufficiently match any subcommand, the default
handling will take over and try to treat it as positional argument.

* added dependency to `strsym` crate
* new `did_you_mean` function uses `strsim::jaro_winkler(...)` to look
  for good candidates.

Related to #103
2015-05-05 17:12:20 -04:00
Sebastian Thiel
d17dcb2920 imp(clap-test): simplified make test invocation
* assure `make test` works on OSX as well
* simplified entire makefile, by basically removing sed invocations to
  manipulate the Cargo.toml file under source control.
* *works for me* predicate

This should probably be tested on another system as well, just to be
sure it makes sense for everyone.
2015-05-05 17:12:20 -04:00
Kevin K
b249f9657c im(arg_enum): allows ascii case insensitivity for enum variants
Allows creating an enum with CamelCase to follow Rust guidelines, but
then will match ascii case insensitive. This means variant
SomeEnum::Emacs would match string "emacs".

Closes #104
2015-05-05 17:12:20 -04:00
Kevin K
632c89bf26 chore(clap): increase version 2015-05-05 17:12:20 -04:00
Kevin K
05476fc61c docs(from_usage): explains new usage strings with multiple values 2015-05-05 17:12:20 -04:00
Kevin K
3d58197674 feat(from_usage): adds ability to add value names or num of vals in usage string
Allows new usage strings with value names or number of values. If the
names are consecutive, they are counted to represent the number of
values (if they all have the same name), or if their names are different
they are used as value names.

Closes #98
2015-05-05 17:12:20 -04:00
Kevin K.
be77f0c5cf Merge pull request #101 from kbknapp/patch-99
Fixes #99 as well as other misc fixes
2015-05-04 22:04:04 -04:00
Kevin K
a87d970c93 tests(run_test.py): update help messages to new fixes 2015-05-04 22:01:28 -04:00
Kevin K
847001ff6d fix(help): fixes tab alignment with multiple values 2015-05-04 22:01:28 -04:00
Kevin K
c1c993c419 im(Options): adds number of values to options in help/usage 2015-05-04 22:01:28 -04:00
Kevin K
45e481cb1c tests(main.rs): adds new features to tests 2015-05-04 22:01:28 -04:00
Kevin K
dd2a75640c fix(MultipleValues): properly distinguishes between multiple values and multiple occurrences
When using number_of_values() or value_names() you no longer have to set
.multiple(true) unless you want the argument to be allowed multiple
times (i.e. *not* the value, but the argument itself). This means
without multiple(true) set (and assuming 2 values) -o val1 val2 is only
allowed one time, but with multiple(true) set, -o val1 val2 -o val3 val4
is allowed.

Closes #99
2015-05-04 21:59:10 -04:00
Kevin K
4a23f1b484 chore(clap): increase version 2015-05-03 20:36:22 -04:00
Kevin K
a1fb94be53 fix(Options): fixes bug where options with no value don't error out 2015-05-03 20:31:56 -04:00
Kevin K
37a925d2b9 chore(clap): increase version 2015-05-03 17:11:05 -04:00
Kevin K
f66334d0ce fix(Options): fixes a bug where option arguments in succession get their values skipped 2015-05-03 17:02:10 -04:00
Kevin K
0b165e28ca chore(clap): increase version 2015-05-03 16:29:17 -04:00
Kevin K
51087b693b style(app.rs): changes to follow Rust style guide 2015-05-03 16:24:44 -04:00