Commit graph

990 commits

Author SHA1 Message Date
Corentin Henry
8578f56568 clippy: if_same_then_else 2017-06-12 07:53:55 -07:00
Corentin Henry
f86edf48b1 clippy: needless_borrow 2017-06-12 07:53:55 -07:00
Corentin Henry
dfcefea6fa clippy: collapsible_if 2017-06-12 07:53:55 -07:00
Corentin Henry
852e9ceb18 clippy: let_and_return 2017-06-12 07:53:55 -07:00
Corentin Henry
2f0e511ab6 clippy doc_markdown 2017-06-12 07:53:55 -07:00
Corentin Henry
be6ce71d33 fix unused_macros warnings for non-yaml build 2017-06-12 07:53:55 -07:00
Corentin Henry
e29590527a fix dead_code warning 2017-06-12 07:53:55 -07:00
Corentin Henry
548bf64e4a remove unused macros 2017-06-12 07:53:55 -07:00
Vanessa McHale
a6c6e81529 typo fixed 2017-06-10 17:43:09 -04:00
Vanessa McHale
0da5820e3b fixes bug with unicode widths 2017-06-10 17:43:09 -04:00
golem131
77763e1e29 Update bitflags 0.8.0 -> 0.9 2017-06-10 17:38:18 -04:00
Martin Geisler
49f9dc166a refactor: let wrap_help return the wrapped string
Earlier, wrap_help was doing in-place modification on the help text.
With the user of the textwrap crate, this is no longer the case and we
can return the string directly.
2017-05-29 20:48:10 -04:00
Martin Geisler
88f26e083e refactor: let textwrap handle long words
The textwrap crate can handle long words fine. By default they're
broken to avoid lines longer than the specified width, but this can be
disabled.
2017-05-29 20:48:10 -04:00
Martin Geisler
f89a012d09 refactor: simply print help text as-is
This should be equivalent to printing the lines one by one.
2017-05-29 20:48:10 -04:00
Martin Geisler
d31fe0322d refactor: avoid unnecessary '\n' checks when generating help
The code handling help texts with newlines can also handle help texts
without newlines.
2017-05-29 20:48:10 -04:00
Martin Geisler
9486f4c3f5 refactor: simplify initialization of help string 2017-05-29 20:48:10 -04:00
Martin Geisler
b93870c10a feat: use textwrap crate for wrapping help texts
The textwrap crate uses a simpler linear-time algorithm for wrapping
the text. The current algorithm in wrap_help uses several O(n) calls
to String::insert and String::remove, which makes it potentially
quadratic in complexity.

Comparing the 05_ripgrep benchmark at commits textwrap~2 and textwrap
gives this result on my machine:

 name              before ns/iter  after ns/iter  diff ns/iter   diff %
 build_app_long    22,101          21,099               -1,002   -4.53%
 build_app_short   22,138          21,205                 -933   -4.21%
 build_help_long   514,265         284,467            -229,798  -44.68%
 build_help_short  85,720          85,693                  -27   -0.03%
 parse_clean       23,471          22,859                 -612   -2.61%
 parse_complex     29,535          28,919                 -616   -2.09%
 parse_lots        422,815         414,577              -8,238   -1.95%

As part of this commit, the wrapping_newline_chars test was updated.
The old algorithm had a subtle bug where it would break lines too
early. That is, it wrapped the text like

    ARGS:
        <mode>    x, max, maximum   20 characters, contains
                  symbols.
                  l, long           Copy-friendly,
                  14 characters, contains symbols.
                  m, med, medium    Copy-friendly, 8
                  characters, contains symbols.";

when it should really have wrapped it like

    ARGS:
        <mode>    x, max, maximum   20 characters, contains
                  symbols.
                  l, long           Copy-friendly, 14
                  characters, contains symbols.
                  m, med, medium    Copy-friendly, 8
                  characters, contains symbols.";

Notice how the word "14" was incorrectly moved to the next line. There
is clearly room for the word on the line with the "l, long" option
since there is room for "contains" just above it.

I'm not sure why this is, but the algorithm in textwrap handles this
case correctly.
2017-05-29 17:02:57 -04:00
nate
d06f819f42 remove public from Colorizer properties and use ColorizerOption instead. 2017-05-29 13:04:47 -04:00
nate
4293013c26 clean up. fix lint and formatting. 2017-05-29 13:04:47 -04:00
nate
53e3d833f1 refactor to add ColorizeOption 2017-05-29 13:04:47 -04:00
nate
f400fa6e7f refactor color macro. refactor Colorizer to have ColorizerOption. 2017-05-29 13:04:47 -04:00
nate
f915f9ce42 add ColorizeOption and add function "new" for Colorizer
it has logic where checking tty is valid and if TERM is dumb when coloring
a message.
2017-05-29 13:04:47 -04:00
nate
3185511f3b when TERM=dumb, the output is colorless #847
comply to
2017-05-29 13:04:47 -04:00
Jacob Mischka
53c1ffe87f fix: Change who's -> whose 2017-05-29 12:58:18 -04:00
Kevin K
826048cb3c docs(clap_app!): adds using the @group specifier to the macro docs
Closes #932
2017-05-16 07:23:22 -04:00
Kevin K
7ad123e2c0 fix: adds a debug assertion to ensure all args added to groups actually exist
Closes #917
2017-05-16 07:23:22 -04:00
Kevin K
cbea3d5acf docs(App::template): adds details about the necessity to use AppSettings::UnifiedHelpMessage when using {unified} tags in the help template
Closes #949
2017-05-16 07:23:22 -04:00
Kevin K
f9b0d65783 docs(Arg::allow_hyphen_values): updates the docs to include warnings for allow_hyphen_values and multiple(true) used together 2017-05-16 07:23:22 -04:00
Kevin K
ab2f4c9e56 fix: fixes a bug where args that allow values to start with a hyphen couldnt contain a double hyphen -- as a value
Closes #960
2017-05-16 07:23:22 -04:00
Kevin K
54c16836de fix: fixes a bug where positional argument help text is misaligned 2017-05-10 20:29:54 -04:00
Kevin K
9f9364b1d8 fix: fixes a bug where args with last(true) and required(true) set were not being printed in the usage string
Closes #944
2017-05-07 10:46:03 -04:00
Kevin K
8713da2372 fix: fixes a bug that was printing the arg name, instead of value name when Arg::last(true) was used
Closes #940
2017-05-07 10:46:03 -04:00
Kevin K
fedb46b5b1 fix: fixes a bug where flags were parsed as flags AND positional values when specific combinations of settings were used
This commit fixes a bug where using `AppSettings::AllowHyphenValues`
would cause flags with longs be *also* parsed as positional values.

Closes #946
2017-05-07 10:46:03 -04:00
Kevin K
52d110df81 docs(AllowHyphenValues): updates the docs to remove old limitations that no longer apply 2017-05-07 10:46:03 -04:00
Nuew
d5ef895541
api(Arg): add default_value_os
Also add related tests, and reframe `default_value` in terms of
`defualt_value_os`.
2017-04-24 15:49:59 -04:00
Pyry Kontio
0a4384e350 api(arg_matches.rs): Added a Default implementation for Values and OsValues iterators. 2017-04-23 23:49:20 +09:00
Kevin K
85b0e1cc4b
imp(PowerShell Completions): massively dedups subcommand names in the generate script to make smaller scripts that are still functionally equiv 2017-04-18 23:17:05 -04:00
Kevin K
a8bce55837
fix(PowerShell Completions): fixes a bug where powershells completions cant be used if no subcommands are defined
Closes #931
2017-04-18 23:01:20 -04:00
Michael Daffin
71dabba3ea docs: Fix a typo the minimum rust version required 2017-04-07 10:02:00 +01:00
Kevin K
6aa4ba8114 fix: fixes a missing newline character in the autogenerated help and version messages in some instances 2017-04-05 10:59:55 -04:00
Kevin K
f7a8877978 feat(clap_app!): adds support for arg names with hyphens similar to longs with hyphens
One can now use `("config-file")` style arg names

Closes #869
2017-04-05 00:57:47 -04:00
Kevin K
bc08ef3e18 docs(clap_app!): documents the --("some-arg") method for using args with hyphens inside them
Closes #919
2017-04-05 00:47:19 -04:00
Kevin K
59272b06cc feat: allows distinguishing between short and long version messages (-V/short or --version/long)
One can now use `App::long_version` to dsiplay a different (presumably
longer) message when `--version` is called. This commit also adds the
corresponding print/write long version methods of `App`
2017-04-05 00:42:43 -04:00
Kevin K
d82b4be5d7 api: adds new App method calls for printing and writing the long version of help messages
One can now use `App::print_long_help` or `App::write_long_help`

Note that `App::write_long_help` is **NOT** affected by kbknapp/clap-rs#808 in the manner
that `App::write_help` help is and thus should be preferred if at all possible.
2017-04-05 00:42:43 -04:00
Kevin K
6b371891a1 feat: allows distinguishing between short and long help with subcommands in the same manner as args
One can use `App::about` for `-h` short help messsages or
`App::long_about` for `--help` long help messages.
2017-04-05 00:42:43 -04:00
Kevin K
ef1b24c3a0 feat: allows specifying a short help vs a long help (i.e. varying levels of detail depending on if -h or --help was used)
One can now use `Arg::long_help` which will be displayed when the user
runs `--help`. This is typically longer form content and will be
displayed using the NextLineHelp methodology.

If one specifies the standard `Arg::help` it will be displayed when the
user runs `-h` (by default, unless the help short has been overridden).
The help text will be displayed in the typical clap fashion.

The help format requested (-h/short or --help/long) will be the
*default* displayed. Meaning, if one runs `--help` (long) but only an
`Arg::help` has been provided, the message from `Arg::help` will be
used. Likewise, if one requests `-h` (short) but only
`Arg::long_help` was provided, `Arg::long_help` will be displayed appropriately
wrapped and aligned.

Completion script generation *only* uses `Arg::help` in order to be
concise.

cc @BurntSushi thanks for the idea!
2017-04-05 00:42:43 -04:00
Kevin K
8b2ceb8368 fix: fixes a bug that wasn't allowing help and version to be properly overridden
One should be able to override the auto generated help and version flags
by simply providing an arg with a long of `help` or `version`
respectively. This bug was preventing that from happening.

However, now that it's fixed if one was relying on adding an arg with a
long of `help` or `version` and using `get_matches_safe` to produce the
`ErrorKind::HelpDisplayed` or `ErrorKind::VersionDisplayed` errors they
**WILL NOT** happen anymore.

This is because the bug was causing those "errors" to occur (i.e. the
help or version message to be displayed). The "fix" to get that
functionality back is to either:

 * Remove the arg with the long of `help` or `version`
 * Use `ArgMatches::is_present` instead of `App::get_matches_safe` to check for the presence of your custom help or version flag

Option 1 is the easiest provided one wasn't using said arg to *also*
override other aspects of the flags as well (short, help message, etc.)

Even though this may break some code, as per the compatibility policy
listed in the readme; code that breaks due to relying on a bug does
*not* constitute a major version bump. I will however be bumping the
minor version instead of just the patch version. I will also be
searching for, contacting, and attempting to submit PRs to any affected
projects prior to releasing the next version to crates.io

Closes #922
2017-04-04 19:59:03 -04:00
Kevin K
f93cadd74b tests: fixes a missing import for a doctest and uses conditional doc-testing 2017-03-30 15:19:17 -04:00
Kevin K
0e4fd96d74 fix(Custom Usage Strings): fixes the usage string regression when using help templates 2017-03-30 13:30:23 -04:00
Kevin K
a442211b39 fix(usage): fixes a big regression with custom usage strings 2017-03-24 11:27:23 -04:00
Richard Janis Goldschmidt
d49e8292b0
api(App::name): adds the ability to change the name of the App instance after creation
Closes #908
2017-03-22 20:27:20 -04:00
CrazyMerlyn
89e6ea861e
api(Arg::hide_default_value): adds ability to hide the default value of an argument from the help string
Adds a new method, `Arg::hide_default_value`, which allows for
specifying whether the default value of the argument should be hidden
from the help string.

Closes #902
2017-03-22 20:26:31 -04:00
CrazyMerlyn
6bf5bf5bee
fix(yaml): adds support for loading author info from yaml
fix(yaml): adds support for loading author info from yaml
2017-03-22 20:23:55 -04:00
Pierre-Eric Pelloux-Prayer
f8f68cf825 imp: add fish subcommand help support 2017-03-17 17:46:24 +01:00
Kevin K
c8eb0384d3
imp: options that use require_equals(true) now display the equals sign in help messages, usage strings, and errors"
Closes #903
2017-03-16 21:43:36 -04:00
Armin Ronacher
e06689fc26 Propagate terminal widths to subcommands 2017-03-16 14:19:10 +01:00
Kevin K
74b751ff2e
fix(ArgRequiredElseHelp): fixes the precedence of this error to prioritize over other error messages
Closes #895
2017-03-12 12:52:09 -04:00
Kevin K
9a3bc98e9b
fix(Positionals): fixes some regression bugs resulting from old asserts in debug mode.
Closes #896
2017-03-12 12:43:10 -04:00
Kevin K
96884aa1b2
refactor: implements PartialEq for some of the base structs 2017-03-11 12:38:24 -05:00
Kevin K
f9668297a4
api(Arg::last): adds the ability to mark a positional argument as 'last' which means it should be used with -- syntax and can be accessed early
Marking a positional argument `.last(true)` will allow accessing this argument earlier if the `--` syntax is used (i.e. skipping other positional args)
and also change the usage string to one of the following:

* `$ prog [arg1] [-- <last_arg>]`
* `$ prog [arg1] -- <last_arg>` (if the arg marked `.last(true)` is also marked `.required(true)`)

Closes #888
2017-03-11 12:14:54 -05:00
Kevin K
989862d2cb
chore: fixes small rebase regression 2017-03-10 15:27:24 -05:00
Kevin K
9d4535e1c3
chore: clippy run 2017-03-10 08:24:30 -05:00
Kevin K
075036c28d
fix: fixes a regression 1.11.0 feature 2017-03-10 08:24:30 -05:00
Kevin K
1e4cce0291
tests: corrects the debug messages from the usage module 2017-03-10 08:24:30 -05:00
Kevin K
d2b4c2c61b
fix: fixes false positive clean parse when the suggestions feature is disabled and InferSubcommands is enabled 2017-03-10 08:24:30 -05:00
Kevin K
b841f3743f
fix: fixes a failing build with no-default-features 2017-03-10 08:24:30 -05:00
Kevin K
d484da0d28
fix: fixes a misspelled import for Windows 2017-03-10 08:24:29 -05:00
Kevin K
33eb5a6db0
tests: fixes failing dual usage string help test 2017-03-10 08:24:29 -05:00
Kevin K
622b609c57
refactor: moves usage string generation code into it's own module 2017-03-10 08:24:29 -05:00
Kevin K
44ed8b663c
refactor: moves validation code into it's own module 2017-03-10 08:24:29 -05:00
Kevin K
c8ab24bafa
imp: when AppSettings::SubcommandsNegateReqs and ArgsNegateSubcommands are used, a new more accurate double line usage string is shown
Closes #871
2017-03-10 08:24:29 -05:00
Kevin K
d63d404e5e
fix: doesn't print the argument sections in the help message if all args in that section are hidden 2017-03-10 08:24:28 -05:00
Kevin K
539ad6073f
fix: doesn't include the various [ARGS] [FLAGS] or [OPTIONS] if the only ones available are hidden
Closes #882
2017-03-10 08:24:28 -05:00
Kevin K
97e8db23b3
fix: now correctly shows subcommand as required in the usage string when AppSettings::SubcommandRequiredElseHelp is used
Close #883
2017-03-10 08:24:28 -05:00
Kevin K
91d8280322
chore: rustfmt run 2017-03-10 08:24:28 -05:00
Kevin K
6f638a53c1
perf: doesn't run arg_post_processing on multiple values anymore 2017-03-10 08:24:28 -05:00
Kevin K
150756b989
setting(InferSubcommands): adds a setting to allow one to infer shortened subcommands or aliases (i.e. for subcommmand "test", "t", "te", or "tes" would be allowed assuming no other ambiguities)
Closes #863
2017-03-10 08:22:31 -05:00
Joost Yervante Damad
8adf353e0b
fix(help): don't show ARGS when there are only hidden positional args
Also no need to check for Hidden inside for that already is filtered
on !Hidden.

Closes #882
2017-03-10 08:22:31 -05:00
Kevin K
24e3839220
perf: changes internal use of VecMap to Vec for matched values of Args
This makes a very big difference for CLIs that parse a large number of
values (think ripgrep over a large directory).

This commit improved the ripgrep parsing of ~2,000 values, simulating
giving ripgrep a bunch of files. Parsing when from ~1,200,000 ns to
~400,000 ns! This was conducted a i7-5600U 2.6GHz
2017-03-10 08:22:31 -05:00
Caleb Jones
c5dac3fa43 Support loading help_message and version_message from the YAML 2017-03-10 01:54:50 -05:00
Caleb Jones
389c413b70 Allow customizing the --version and --help messages 2017-03-10 01:01:56 -05:00
Anthony Ramine
f4939ad560 Remove direct dependency on libc
It's not actually used anymore anywhere.
2017-03-05 19:44:16 +01:00
Kevin K
8da0303bc0
perf: vastly reduces the amount of cloning when adding non-global args minus when they're added from App::args which is forced to clone 2017-02-28 08:30:14 -05:00
Kevin K
0a922e5f61
tests: adds parsing cases to ripgrep bench 2017-02-28 08:30:14 -05:00
Kevin K
0efa411963
perf: refactor to remove unneeded vectors and allocations and checks for significant performance increases
Building an `App` struct with a fair number of args/flags/switches, etc. (used ripgrep as test case)
went from taking ~21,000 ns to ~13,000ns.
2017-02-28 08:30:13 -05:00
Kevin K
b55cae5fdb
refactor: removes unused fields and moves some bools to bitfields 2017-02-28 08:30:09 -05:00
Corey Farwell
5ee2665e7a Implement ExactSizeIterator for Values. (#877) 2017-02-26 23:20:52 -05:00
Kevin K
6bf94606c2
test: fixes failing doc test 2017-02-22 20:37:56 -05:00
Marco A L Barbosa
fa26d40a18 Fix missing line before code block 2017-02-22 11:25:10 -03:00
Kevin K
588f373ea8
chore: rustfmt run 2017-02-20 21:16:14 -05:00
Kevin K
8c2dd28718
fix: fixes some memory leaks when an error is detected and clap exits 2017-02-20 21:16:07 -05:00
Kevin K
6b5725836f Merge branch 'master' into issues-833,849 2017-02-20 20:36:15 -05:00
Kevin K
1ae2110801
fix: fixes a trait that's marked private accidentlly, but should be crate internal public 2017-02-20 20:31:57 -05:00
Kevin K
10ca4d1e21
chore: rustfmt run 2017-02-20 20:24:28 -05:00
Kevin K
f002693dec
feat(Options): adds the ability to require the equals syntax with options --opt=val
Closes #833
2017-02-20 20:24:27 -05:00
Kevin K
e0f7722685
style: improves the style of doc tests and examples to increase readability and uniformity 2017-02-20 20:24:27 -05:00
Kevin K
0f2a378219
api: provides default_value_os and default_value_if[s]_os
One can now define default values that contain invalid UTF-8.

The underlying implementation has also been changed to use OsStrs in order to avoid duplication
of code and provide the new APIs basically for free.

Closes #849
2017-02-20 20:24:24 -05:00
Kevin K
fb7057cc7a
refactor(Arg): removes duplicate and uses Base, Switched, and Valued internally now 2017-02-20 19:06:36 -05:00
Kevin K
65b12f9107
chore: clippy run 2017-02-20 19:06:36 -05:00
Niklas Claesson
1971209c0c Fix minor documentation bug 2017-02-20 23:13:06 +01:00
Peter Williams
68e03681d8 refactor: use the atty crate for isatty() detection
Not only does this remove some unsafe code from clap itself, `atty` does the
right thing on Windows too. This isn't relevant now since we don't currently
support colorized output on Windows, but will come in handy if/when we
implement that feature (#836).
2017-02-19 11:12:55 -05:00
Eduard-Mihai Burtescu
f28b2353b2 Add missing fragment specifier to a clap_app! rule. 2017-02-18 12:03:41 +02:00
Peter Williams
e635658dad tests: fix clap_app! doctest 2017-02-16 10:48:34 -07:00
Kevin K
e3296e566b Docs (#854)
* docs(App::template) adds missing categories and fixes descriptions

* docs(clap_app): documents all the shorthand syntax

Closes #736

* chore: fixes crates.io category...hopefully
2017-02-16 09:44:44 -05:00
Kevin K
5e9b9cf4dd
fix(Completions): fixes a bug that tried to propogate global args multiple times when generating multiple completion scripts
Closes #846
2017-02-15 11:01:41 -05:00
Kevin K
92919f5f67 Call this PR "Raid" cause it's squashin bugs! (#843)
* tests: adds tests for default values triggering conditional requirements

* fix: fixes a bug where default values should have triggered a conditional requirement but didnt

Closes #831

* tests: adds tests for missing conditional requirements in usage string of errors

* fix: fixes a bug where conditionally required args werent appearing in errors

* tests: adds tests for completion generators

* tests: adds tests for completions with binaries names that have underscores

* fix: fixes a bug where ZSH completions would panic if the binary name had an underscore in it

Closes #581

* fix: fixes bash completions for commands that have an underscore in the name

Closes #581

* chore: fix the category for crates.io

* docs(Macros): adds a warning about changing values in Cargo.toml not triggering a rebuild automatically

Closes #838

* fix(Completions): fixes a bug where global args weren't included in the generated completion scripts

Closes #841

* fix: fixes a println->debugln typo

* chore: increase version
2017-02-03 17:43:49 -05:00
Kevin K
07d985d8c5 Issues 839,840 (#842)
* fix: fixes a critical bug where subcommand settings were being propogated too far

Closes #832

* imp: adds ArgGroup::multiple to the supported YAML fields for building ArgGroups from YAML

Closes #840

* chore: increase version
2017-02-03 15:46:25 -05:00
Martin Geisler
564c5f0f17 fix: allow final word to be wrapped in wrap_help
Before, inserting a newline did not move the prev_space index forward.
This meant that the next word was measured incorrectly since the
length was measured back to the word before the newly inserted
linebreak.

Fixes #828.
2017-01-30 18:33:48 +01:00
Martin Geisler
84d8c5476d fix: actually show character in debug output
The &help[j..j] string slice was empty so nothing was shown.
2017-01-30 18:33:48 +01:00
Martin Geisler
aff4ba18da fix: include final character in line lenght
Before, wrapping the help text at, say, 80 characters really meant
that every line could be at most 79 characters wide.

Lines can now be up to and including avail_chars columns wide.

If needed, a desired margin or padding can be subtracted from the
avail_chars argument at a later point.
2017-01-30 18:33:48 +01:00
Kevin K
69bd16c410
chore: clippy run 2017-01-29 21:19:00 -05:00
Richard Janis Goldschmidt (Beckert)
f9f778e8a4 Fix finding required arguments in group arguments (#829)
This fixes #827. The problem was that the check `grp.args.contains(&grp.args[i])` was a) trivially fulfilled (of course `grp.args[i]` is contained in `grp.args`) and b) causing an out-of-bounds error, since the indices were taken from `.required.len()`.

With this change the argument in the group will be removed from the list of required arguments, as intended.
2017-01-29 18:14:04 -08:00
Trevor Spiteri
5b29be9b07 docs: fix link from app_from_crate! to crate_authors! (#822) 2017-01-29 18:13:34 -08:00
Richard Janis Goldschmidt (Beckert)
ed52851c5d Fix confusing, wrong wording in doc (#821) 2017-01-29 18:12:54 -08:00
Richard Janis Goldschmidt
f1b11886dc Explain how AppSettings::ArgRequiredElseHelp and Arg::default_value interact
When calling the executable without arguments one expects a help message. However, if even one argument has a default value, the validation step of the parser will always see at least one argument, and therefore report success. This effectively disables the settings.
2017-01-18 17:14:06 +01:00
pixelistik
5de1b6e1c8 doc: Fix typo 2017-01-08 23:45:03 +01:00
Brian Bowman
4f30a65b9c docs: fix spelling of "guaranteed" 2017-01-07 20:18:59 -06:00
Kevin K
9d88f19181
refactor: 'reverts' a breaking change until further discussion and approval has taken place 2017-01-05 19:26:16 -05:00
Kevin K
6edde30b8e
setting(AllowMissingPositional): allows one to implement $ prog [optional] <required>
Closes #636
2017-01-04 00:02:26 -05:00
Kevin K
985536c8eb
setting(PropagateGlobalValuesDown): adds a setting to allow automatically propagating global args values down through *used* subcommands
Closes #694
2017-01-02 23:05:50 -05:00
Kevin K
20842ed8c2
fix: fixes an issue where the full help message wasn't written when doing App::write_help
Closes #801
2017-01-02 23:05:50 -05:00
Kevin K
ad4691b71a
feat(Help Wrapping): long app names (with spaces), authors, and descriptions are now wrapped appropriately
Closes #777
2017-01-02 16:43:45 -05:00
Kevin K
1f33de5450
imp(Default Values): improves the error message when default values are involved
Closes #774
2017-01-02 16:43:07 -05:00
Kevin K
26c670ca16
fix(Low Index Multiples): fixes a bug which caused combinations of LowIndexMultiples and allow_hyphen_values to fail parsing 2017-01-02 14:33:56 -05:00
Kevin K
baff4200a4
refactor: implements BitOr for AppFlags to improve some ergonomics and performance 2017-01-02 12:23:03 -05:00
Kevin K
be64ce0c37
api(Arg::value_terminator): adds the ability to terminate multiple values with a given value
One can now specificy a value termintaor that will stop the parsing of multiple values upon
reaching this special value.

Closes #782
2017-01-02 12:23:03 -05:00
nabijaczleweli
4d9a82db8e
feat(simple-cargo-app): Implement crate_description!, crate_name! and app_from_crate! macros
Closes #778
2016-12-31 14:25:59 +01:00
Kevin K
5e2af8c96a
setting: adds a setting to disable args being allowed between subcommands (ArgsNegateSubcommands)
Specifies that use of a valid [argument] negates [subcomands] being used after. By default
`clap` allows arguments between subcommands such as
`<cmd> [cmd_args] <cmd2> [cmd2_args] <cmd3> [cmd3_args]`. This setting disables that
functionality and says that arguments can only follow the *final* subcommand. For instance
using this setting makes only the following invocations possible:

* `<cmd> <cmd2> <cmd3> [cmd3_args]`
* `<cmd> <cmd2> [cmd2_args]`
* `<cmd> [cmd_args]`

Closes #793
2016-12-30 23:21:28 -05:00
Kevin K
c2978afc61
setting: adds a new setting to disable the collapsing of positional args into [ARGS] in the usage string (DontCollapseArgsInUsage)
Closes #769
2016-12-30 22:38:42 -05:00
Kevin K
c20701b74a
chore: clippy run 2016-12-30 22:08:28 -05:00
Kevin K
a10fc859ee
setting: adds a setting to disable building the help subcommand (DisableHelpSubcommand)
Relates to #787
2016-12-30 21:52:45 -05:00
Kevin K
d34ec3e032
fix(Help Subcommand): fixes a bug where the help subcommand couldn't be overriden
Closes #787
2016-12-30 21:37:09 -05:00
Kevin K
5a5f2b1e9f
fix(Options): fixes a critical bug where options weren't forced to have a value
For instance imagine --opt <val> and --opt2 <val>

Running:

```
$ prog --opt --opt2 val
```

Would pass. This has been fixed.

Closes #665
2016-12-30 16:17:47 -05:00
Kevin K
988b9cbea4
style: standardizes debug calls and output
Closes #792
2016-12-29 23:34:46 -05:00
Kevin K
280bb85f69 Merge branch 'master' into issue-764 2016-12-28 23:58:11 -05:00
Kevin K
3055e77ea7
tests(YAML): adds some of the new APIs to the YAML tests 2016-12-28 23:56:33 -05:00
Kevin K
9a4df32789
imp(YAML): adds conditional requirements and conditional default values to YAML
All of the conditional default values and conditional requirements
(requried and requires) can now be used with YAML builders as well.

Closes #764
2016-12-28 23:34:29 -05:00
Kevin K
ee9cfddf34
feat(Conditionally Required): adds the ability for an arg to be conditionally required
An arg can now be conditionally required (i.e. it's only required if arg
A is used with a value of V).

For example:

```rust
let res = App::new("ri")
	.arg(Arg::with_name("cfg")
	    .required_if("extra", "val")
	    .takes_value(true)
	    .long("config"))
	.arg(Arg::with_name("extra")
	    .takes_value(true)
	    .long("extra"))
	.get_matches_from_safe(vec![
	    "ri", "--extra", "val"
	]);

assert!(res.is_err());
assert_eq!(res.unwrap_err().kind, ErrorKind::MissingRequiredArgument);
```

Relates to #764
2016-12-28 23:30:52 -05:00
Kevin K
4ef091019c
docs(Conditional Default Values): fixes the failing doc tests of Arg::default_value_ifs 2016-12-28 23:28:21 -05:00
Kevin K
7f296e29db
docs(Conditional Requirements): adds docs for Arg::requires_ifs 2016-12-28 23:28:21 -05:00
Kevin K
198449d643
feat(Conditional Requirements): adds the ability to conditionally require additional args
An arg can now conditionally require additional arguments if it's value matches a specific value.

For example, arg A can state that it only requires arg B if the value X was used with arg A. If any
other value is used with A, arg B isn't required.

Relates to #764
2016-12-28 23:28:21 -05:00
Kevin K
eb4010e7b2
feat(Conditional Default Values): adds new Arg::default_value_if[s] methods for conditional default values
One can now implement conditional default values. I.e. a default value that is only applied in
certain conditions, such as another arg being present, or another arg being present *and*
containing a specific value.

Now it's possible to say, "Only apply this default value if arg X is present" or "Only apply this
value if arg X is present, but also only if arg X's value is equal to Y"

This new method is fully compatible with the current `Arg::default_value`, which gets set only if
the arg wasn't used at runtime *and* none of the specified conditions were met.

Releates to #764
2016-12-28 23:21:40 -05:00
Kevin K
a7186fa8fe Merge branch 'master' into master 2016-12-28 12:01:11 -05:00
Kevin K
68dadde061 Merge branch 'master' into issue-shortcircuit-help 2016-12-28 09:33:16 -05:00
Oliver Smith
17d70dc38e Merge branch 'master' into master 2016-12-28 12:33:23 +00:00
glowing-chemist
1da29a6266 proper OsString conversion 2016-12-28 12:30:50 +00:00
Kevin K
d3d34a2b51
fix: fixes a bug where calling the help of a subcommand wasn't ignoring required args of parent commands
Closes #789
2016-12-28 04:25:58 -05:00
Jędrzej
6fdd2f9d69 feat(no_cargo): add no_cargo feature to disable Cargo-env-var-dependent macros (#786) 2016-12-27 21:07:59 -05:00
glowing-chemist
47232498a8 feat(Validators): adds ability to validate invalid UTF-8 2016-12-27 23:16:28 +00:00
glowing-chemist
f49fb88aa2 updated 2016-12-27 16:19:42 +00:00