Commit graph

1038 commits

Author SHA1 Message Date
Kevin K
91e275c609
Use short help as tooltip in PowerShell completion
Also fixed some small issues with subcommand detection.
2018-03-19 17:12:10 -04:00
Kevin K
bd5143d1f8
fish: Fix completion of >1 options 2018-03-19 17:12:06 -04:00
Kevin K
92eab59dfc
docs: Fix some typos and markdown issues. 2018-03-19 17:11:59 -04:00
andy boot
a4d080370c fix typo 2018-03-19 16:48:01 -04:00
Kevin K
82ffb821de
refactor(Arg): reverts some of the v3 deprecations to ease the upgrade process 2018-03-19 16:33:56 -04:00
Will Murphy
742aec292c Print ARGS after usage in help
For version 3, we want the args section to immediately follow
the usage section in the default help message.

One change that I am unhappy with is needing to make "write_arg"
in app/help.rs accept an extra param that makes it suppress the
extra line. This is to prevent an extra blank line from appearing
between args and options in the default help, and seems necessary,
but there might be a better way.
2018-03-11 20:33:13 -04:00
Will Murphy
23a48ea03a vec_map must be optional
This adds a keys method to the internal implementation of vec_map and
adds conditional compilation in the parser to make the parser compile
with or without the vec_map dependency.
2018-03-04 15:50:35 -05:00
Will Murphy
5ea7eab427 Port 1161 fix to v3
Copy the fix from https://github.com/kbknapp/clap-rs/pull/1162 into
the v3 parser, and add a test to protect against regressions in the
expected behavior of example 22.
2018-03-01 06:52:30 -05:00
Kevin K
e0b891d784
style: removes unused imports 2018-02-13 15:47:31 -05:00
Kevin K
6971624428
imp(Deps): doesnt compile ansi_term on Windows since its not used
Before this commit, ansi_term was compiled anytime the `color` feature
was used. However, on Windows the `color` feature is ignored. Even so
ansi_term was compiled, and just not used. This commit fixes that by
only compiling ansi_term on non-Windows targets. Thanks to @retep998 for
the gudiance.

Closes #1155
2018-02-13 15:43:45 -05:00
Kevin K
79a210472c
imp(Bash Completions): instead of completing a generic option name, all bash completions fall back to file completions UNLESS Arg::possible_values was used 2018-02-13 15:42:47 -05:00
Kevin K
08dfdc877b
style: changes values->possible values in help messages as well as errors 2018-02-12 14:52:29 -05:00
etopiei
5220122f72
Adjusted error message, as specified in Issue #1160 2018-02-12 14:39:51 -05:00
Kevin K
7c23bee6b8
setting(AllArgsOverrideSelf): adds a convenience setting to say all args override themselves 2018-02-10 15:42:44 -05:00
Kevin K
db237f3ed2
docs(Self Overrides): adds docs to better explain overrides_with 2018-02-09 23:34:58 -05:00
Kevin K
4204787e0f
imp(Self Overrides): allows args to override themselves properly 2018-02-09 23:34:36 -05:00
Kevin K
300a059f51
chore: updates the version tests 2018-02-03 15:22:56 -05:00
Kevin K
cf3eaaeb0c
tests: fixes some typos that caused failing doc tests 2018-02-03 15:14:34 -05:00
Kevin K
41436d3b7d
docs(Arg.rs): updates documentation for the deprecations 2018-02-03 15:06:56 -05:00
Kevin K
6fc70d825c
depr(Arg.rs): adds deprecations in prep for v3
A full list of deprecations is:

* Arg::last -> ArgSettings::Last
* Arg::required -> ArgSettings::Required
* Arg::require_equals -> ArgSettings::RequireEquals
* Arg::allow_hyphen_values -> ArgSettings::AllowHyphenValues
* Arg::takes_value -> ArgSettings::TakesValue
* Arg::hide_possible_values -> ArgSettings::HidePossibleValues
* Arg::hide_default_value -> ArgSettings::HideDefaultValue
* Arg::multiple -> ArgSettings::Multiple (see Arg::multiple split)
* Arg::multiple -> ArgSettings::MultipleValues (see Arg::multiple split)
* Arg::multiple -> ArgSettings::MultipleOccurrences (see Arg::multiple split)
* Arg::global -> ArgSettings::Global
* Arg::empty_values -> ArgSettings::AllowEmptyValues
* Arg::hidden -> ArgSettings::Hidden
* Arg::case_insensitive -> ArgSettings::IgnoreCase
* Arg::use_delimiter -> ArgSettings::UseDelimiter
* Arg::require_delimiter -> ArgSettings::RequireDelimiter
* Arg::hide_env_values -> ArgSettings::HideEnvValues
* Arg::next_line_help -> ArgSettings::NextLineHelp
* Arg::set -> Arg::unset_setting (consistent naming with App)
* Arg::unset -> Arg::setting (consistent naming with App)

Relates to #1037
2018-02-03 15:00:55 -05:00
Kevin K
04b7532bcb
docs(App.rs): updates the docs away from deprecated methods 2018-01-30 21:10:35 -05:00
Kevin K
c441467de3
depr(App.rs): deprecates old App methods in prep for v3
A full list of deprecations is:

* App::version_message -> App::mut_arg
* App::version_short -> App::mut_arg
* App::help_message -> App::mut_arg
* App::help_short -> App::mut_arg
* App::from_yaml -> serde
* App::usage -> App::override_usage (+no longer assumes leading \t)
* App::help -> App::override_help
* App::template -> App::help_template
* App::args_from_usage -> App::args(&str)
* App::arg_from_usage -> App::arg(Arg::from)
* App::write_help -> &self -> &mut self (#808)
* App::gen_completions -> clap_completions::generate
* App::gen_completions_to -> clap_completions::generate_to
* App::get_matches_safe -> App::try_get_matches (#950 Lib Blitz naming
consistency)
* App::get_matches_from_safe -> App::try_get_matches_from (#950 Lib Blitz
naming consistency)
* App::get_matches_safe_borrow -> App::try_get_matches_from_mut (#950 Lib
Blitz naming consistency)
2018-01-30 21:04:19 -05:00
Kevin K
1fa4afa45d
tests: continues to update tests to take advantage of new internals 2018-01-25 22:54:05 -05:00
Kevin K
7788ef70d9
wip: continuing to iron out the bugs from the internal refactor 2018-01-25 22:36:20 -05:00
Kevin K
7673dfc085
perf: refactors the POSIX override handling to lazy handling
This commit primarily changes to a lazy handling of POSIX overrides by
relying on github.com/bluss/ordermap instead of the old HashMap impl.
The ordermap allows us to keep track of which arguments arrived first,
and therefore determine which ones should be removed when an override
conflict is found.

This has the added benefit of we no longer have to do the bookkeeping to
keep track and override args as they come in, we can do it once at the
end.

Finally, ordermap allows fast Vec like iteration of the keys, which we
end up doing several times. Benching is still TBD once the v3 prep is
done, but this change should have a meaningful impact.
2018-01-25 15:08:57 -05:00
Kevin K
e890b647f3
wip: still setting the stage for v3 2018-01-25 12:29:36 -05:00
Kevin K
1ab10275e4
style: rustfmt run 2018-01-25 12:21:17 -05:00
Kevin K
6705195449
wip: setting the stage for serde, custom derive, and v3 2018-01-25 12:20:04 -05:00
Kevin K
4f3231a51c fix(Help): fixes an issue where help is not properly written using App::write_help
Contains a *MINOR* breaking change. App::write_help now requires `&mut self` instead of `&self`.

This fixes a major bug where the help message is entirely incorrect.
More can be found at https://github.com/kbknapp/clap-rs/issues/808

I've decided to make this change because it was preventing further progress.

Anyone's code who breaks the fix is trivial:

```rust
// OLD BROKEN
let app = App::new("broken");
let mut out = io::stdout();
app.write_help(&mut out).expect("failed to write to stdout");

// NEW FIX
let mut app = App::new("broken");  // <-- let mut
let mut out = io::stdout();
app.write_help(&mut out).expect("failed to write to stdout");
```

Closes #808
2018-01-24 11:34:14 -05:00
Kevin K
acdbd47152 wip: changes to builders in prep for v3 2018-01-24 11:34:14 -05:00
Kevin K
d03d13399f
Merge branch 'master' into issue-1135 2018-01-20 15:27:58 -05:00
Will Murphy
4896e817be clean up comments 2018-01-18 20:45:31 -05:00
Will Murphy
74976a0df9 Implement required_unless for flag
Flags were incorrectly reporting that they never had required_unless args.
2018-01-18 20:34:22 -05:00
Will Murphy
c6c9d9b33f Merge branch 'master' into issue-1135 2018-01-18 20:32:44 -05:00
Kevin K
6e66eac2ff
Merge branch 'master' into patch-1 2018-01-18 15:07:17 -05:00
Kevin K
5bb926ebf9 chore: fix html_doc_root 2018-01-18 15:06:23 -05:00
discosultan
61cf3f9142 Fix typo in arg.rs 2018-01-18 15:46:20 +01:00
Segev Finer
25561decf1 feat(completions/zsh.rs): Escape possible values for options 2018-01-16 01:55:48 +02:00
Segev Finer
2cbbfa8ce9 style(completions/zsh.rs): Cleanup documentation and naming 2018-01-16 01:52:44 +02:00
Segev Finer
f3b0afd2be feat(completions/zsh.rs): Implement postional argument possible values completion 2018-01-16 01:52:44 +02:00
Segev Finer
a652260795 fix(completions/zsh.rs): Add missing autoload for is-at-least 2018-01-15 20:41:08 +02:00
Kevin K
e077e0c930
Merge branch 'master' into zsh-completion-improvements 2018-01-15 11:53:25 -05:00
Kevin K
a46ff132f1
Merge branch 'master' into patch-1 2018-01-15 11:52:21 -05:00
Segev Finer
16b4f143ff fix(completions/zsh.rs): Don't pass -S to _arguments if Zsh is too old
If you do pass it than _arguments considers -C as a possible option in
the completions.
2018-01-14 07:13:27 +02:00
Segev Finer
1146f0da15 fix(completions/zsh.rs): Maybe fix completions with mixed positionals and subcommands
Optional positionals mixed with subcommands will still break this, since
I can't see how to tell which element of $line is the command than.
Mixing optional positionals with subcommands is a bit weird and awkward
though...
2018-01-14 07:13:23 +02:00
Segev Finer
e39aeab848 feat(completions/zsh.rs): Complete positional arguments properly
This changes the way we complete positionals to complete them using
_arguments, as should be done, instead of completing their uppercase name
as a string.

Currently I made it offer _files completion for all positional arguments.
This can be improved to complete actual possible values of the arguments
and only complete files if the argument truly takes them. But this will
require further changes in clap to actually have the required
functionality to get this information.
2018-01-14 07:12:14 +02:00
Will Murphy
dc0d8ba89c note-to-self comments 2018-01-13 16:32:45 -05:00
Matt Kraai
b83f387b80
Fix typo 2018-01-10 21:01:21 -08:00
Segev Finer
0e185b922e fix(completions/zsh.zsh): Remove redundant code from output
Fixes #1142
2018-01-10 20:29:01 +02:00
Kevin K
3e97085e58 chore: udpates html doc root 2018-01-09 12:02:35 -05:00