Pavan Kumar Sunkara
6a395d3208
ArgMacthes::is_present should not deal with subcommands at all, fixes #2494
2021-05-26 00:40:38 +01:00
Ajeet D'Souza
5809ae6060
feat: Add AppSettings::DisableEnv ( #2493 )
...
* Add DisableEnv flag
* Apply formatting
* Add tests
2021-05-21 00:47:47 +05:30
Ajeet D'Souza
460459c771
fix(usage): Move positional args to end of usage string ( #2492 )
...
* Move positional args to end of USAGE
* Remove -- from usage string
2021-05-21 00:29:21 +05:30
Eldritch Cheese
fa991754d3
imp(validator): Case-insensitive required_if_eq when arg is case-insensitive
2021-05-15 09:45:24 -07:00
Peter Kolloch
e89f1e6c4d
Input.insert: No need to clone
2021-05-13 13:29:01 +02:00
liudingming
529c55f753
Relax trait bound on clap Error source
2021-05-08 01:56:13 +08:00
liudingming
64e226ef33
Add multiple_* parsing for yaml
2021-05-07 14:34:03 +08:00
sharnoff
5ec28b6093
add missing $crate::
in clap_app!
2021-04-25 19:00:19 -07:00
Pavan Kumar Sunkara
9c99c358c6
Merge pull request #2440 from reaganmcf/app-setting-subcommand-help-long-form
...
setting: UseLongFormatForHelpSubcommand
2021-04-13 04:42:51 +05:30
Reagan McFarland
b184dc001b
setting: SubcommandHelpShowsLongForm implemented
...
Refactoring and better test cases
Refactored SubcommandHelpShowsLongForm to
UseLongFormatForHelpSubcommand.
Tests and docuemntation examples use about and long_about instead of
(before/after)_help.
Removed commented out tests
Linting: Fix trailing new line
Updated change log, refactored tests and doc str
Reordered items in the Changelog
New test added and old tests removed that were redundant
Doc string for AppSettings::UseLongFormatForHelpSubcommand fixed
2021-04-11 14:31:40 -04:00
Pavan Kumar Sunkara
3c9cc0cf91
Specify dep patch versions
2021-04-11 10:38:13 +01:00
Pavan Kumar Sunkara
52814b893c
Merge pull request #2415 from cbzehner/ignore-extra-fields-on-arg
...
Ignore extra fields in Arg yaml definitions
2021-03-14 14:00:30 +05:30
Pavan Kumar Sunkara
4e3b4589ee
Merge pull request #2411 from clap-rs/upgrader
...
Cleanup and add changelog
2021-03-14 14:00:16 +05:30
Chris Zehner
407e629523
Ignore extra fields in Arg yaml definitions
2021-03-13 19:46:38 -06:00
Pavan Kumar Sunkara
d9fb11eba2
Apply cargo-intraconv
2021-03-13 14:11:47 +05:30
Pavan Kumar Sunkara
f029047c03
Rename NoEmptyValues to ForbidEmptyValues
2021-03-13 12:05:34 +05:30
ldm0
d36b201fd6
Apply suggestions
2021-03-11 05:22:08 +00:00
ldm0
a1d4bd8488
Allow empty value by default, introduce NoEquals Error
2021-03-10 17:39:50 +00:00
Pavan Kumar Sunkara
30d784ffd1
Merge pull request #2400 from ldm0/unset-default
...
Support unsetting/removing the default if an option/flag is set
2021-03-10 18:13:52 +05:30
ldm0
448ff95fb0
ldm0's patch
2021-03-09 19:06:44 +00:00
Steven Engler
766dec8319
fixup! feat(build/arg/mod.rs): default_vals_if supports an Option as the default
2021-03-09 18:15:20 +00:00
Steven Engler
6626365359
feat(build/arg/mod.rs): default_vals_if supports an Option as the default
2021-03-09 18:15:20 +00:00
ldm0
2b0f0d3e1a
Implement NoEquals error
2021-03-09 17:56:57 +00:00
Pavan Kumar Sunkara
42c03775b5
Merge pull request #2395 from loloicci/improve-doc-error-exit
...
Improve the document of exit of parse::Errors
2021-03-09 23:20:04 +05:30
loloicci
06c2187f9e
docs: improve the document of exit of parse::Error
2021-03-09 23:37:45 +09:00
ldm0
0b1d137ee9
Apply suggestions
2021-03-09 13:52:12 +00:00
ldm0
6df56ad289
Move checker to macro(better panic message)
2021-03-09 13:45:11 +00:00
ldm0
886b873709
Demangle interlinking flags
2021-03-09 13:45:11 +00:00
ldm0
2bedad2bfa
Split debug_asserts from Arg
2021-03-09 13:45:11 +00:00
loloicci
0a6f086b8e
feat: implement print to parse::Error
...
Implement print to parse::Error.
It just prints formatted error messages and does not exit program.
2021-03-09 18:27:04 +09:00
Pavan Kumar Sunkara
09009761ec
Merge pull request #2368 from integer32llc/more-getters
...
Allow getting the long about, env, and default values of an argument
2021-03-05 22:53:28 +05:30
Jake Goulding
30840d6f35
Allow getting the long about, env, and default values of an argument
...
Closes #2367
2021-03-05 11:02:18 -05:00
Christoph Prokop
676a2d24b6
Fix code example to match help text
...
Signed-off-by: Christoph Prokop <christoph.prokop@mailbox.org>
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Reviewed-by: Matthias Beyer <mail@beyermatthias.de>
2021-03-05 10:04:37 +01:00
dylni
8a6881169b
Upgrade os_str_bytes
2021-03-01 17:58:53 -05:00
Omar El Halabi
701a4610b3
feat: Implement Arg::required_if_eq_all
2021-02-28 14:52:34 +02:00
Logan SQUIREL
3c049b4e22
Fix compatibility with help2man output (see #1432 )
...
Change default help template:
- The new template introduce new lines before and after
author/about sections.
- Add help template placeholders:
- about-section
- author-section
- Documentation of new placeholders in clap::App::help_template
- Update all unit tests by incorporating new lines
2021-02-27 16:20:52 +01:00
Andreas Molzer
c6ea3720ab
Optimize common case of space padding
2021-02-25 13:26:39 +01:00
Logan SQUIREL
f74af655ce
Apply @pksunkara review
2021-02-22 09:37:29 +01:00
Logan SQUIREL
22b5d34693
imp: Visible aliases for arguments in completions ( #2335 )
...
Following changes are implemented:
- Add 'clap::Arg::get_visible_aliases(&self)' method
This new method provides access to visible argument aliases
- Add 'clap::Arg::get_short/long_and_visible_aliases
This new method provides access to the short/long arguments and its
visible aliases
- Add visible aliases completions in clap_generate for following shells:
- Bash
- Elvish
- Fish
- Powershell
- Zsh
- Add test fixtures for testing visible alias completions in clap_generate:
'clap_generate/tests/completions/<shell>::<shell>_with_aliases()'
2021-02-22 09:36:08 +01:00
Pavan Kumar Sunkara
1602b103cd
Fix typo in crate_license
docs
2021-02-20 22:08:48 +00:00
Martin Geisler
df7a8c1282
feat: remove direct unicode-width dependency
...
This removes the direct dependency on unicode-width and delegates the
complexity of computing the displayed width of text to the Textwrap
crate.
The `display_width` function handles characters like “æøå” (Danish),
“äöü” (German), and “😂 ✨ 😍 ” (emojis) – even if the unicode-width
Cargo feature is disabled.
This is an improvement of the former `str_width` function which would
over-estimate the width of emojis and non-ASCII characters (since they
are several bytes wide).
2021-02-20 20:56:15 +01:00
Pavan Kumar Sunkara
80cbc1e695
Merge pull request #2350 from ldm0/num_vals
...
Change how num_vals, min_vals, max_vals interacts with Multiple*
2021-02-18 21:07:26 +00:00
ldm0
2d26f02605
Add --all-features for CI, fix build with debug feature.
2021-02-17 04:37:08 +00:00
ldm0
28b58af63b
Change to num_vals, min_vals, max_vals interacts with Multi*
2021-02-16 03:45:20 +00:00
Collin Styles
2b45011c9b
Update docs for required_unless_present_any
( #2347 )
...
* docs: Correct method name in example
This looks like it was copied from the documentation for
`required_unless_present_all` but not updated accordingly for this
method.
* docs: Add note re `required_unless_present_all` to `required_unless_present_any`
There's a note in the documentation for `required_unless_present_all`
telling users to check out `required_unless_present_any` if that's what
they want. I figured it might be useful to have a similar note in the
documentation for `required_unless_present_any` pointing to that method
as well.
* docs: Fix `required` link in docs for `required_unless_present_all`
* docs: Correct "if" to "unless"
2021-02-15 08:20:11 +00:00
ldm0
73c682b652
Small code shrinking
2021-02-14 13:07:21 +00:00
ldm0
5cff16b6f9
Limit usage of inc_occurence_of
2021-02-14 11:21:12 +00:00
ldm0
78d7252b03
Remove Parser::need_more_vals
2021-02-14 11:21:12 +00:00
Pavan Kumar Sunkara
a8c9d28ead
Merge pull request #2346 from ldm0/non_fmt_panic_fix
...
Fix part of the non_fmt_panic warnings, bump version-sync to 0.9.2
2021-02-14 01:58:26 +00:00
Pavan Kumar Sunkara
5025ed3bee
Merge pull request #2345 from ldm0/usize
...
Change some u64 to usize
2021-02-14 01:57:53 +00:00
ldm0
ddb53af5dc
Change some u64 to usize
2021-02-13 15:25:40 +00:00
ldm0
580d8d2c63
Fix part of the non_fmt_panic
2021-02-12 17:35:15 +00:00
Pavan Kumar Sunkara
6634444c3c
Remove Arg::settings to be consistent with App
2021-02-12 10:42:38 +00:00
Pavan Kumar Sunkara
8eb5081b53
Update changelog
2021-02-10 23:33:14 +00:00
Pavan Kumar Sunkara
2b5a23597a
Better help message support for hidden and heading stuff
2021-02-08 05:22:27 +00:00
Pavan Kumar Sunkara
3758bba5e2
Remove help_about in favor of mut_arg
2021-02-07 17:22:56 +00:00
Pavan Kumar Sunkara
b824e0b088
Allow nested subcommands mutated generated args to take preference
2021-02-07 16:28:49 +00:00
Pavan Kumar Sunkara
423e2dde00
Remove version_about in favor of mut_arg
2021-02-07 16:14:07 +00:00
Pavan Kumar Sunkara
1bd902370a
Add tests for mut_arg on help and version
2021-02-07 15:54:24 +00:00
Pavan Kumar Sunkara
93a737a4fa
Merge pull request #2333 from clap-rs/build_help_and_version_at_start
...
Build help and version args at the beginning
2021-02-07 15:53:45 +00:00
Pavan Kumar Sunkara
c9cb22905c
Build help and version args at the beginning
2021-02-07 14:46:38 +00:00
ldm0
899b04f481
Remove clone
2021-02-07 05:40:02 +00:00
ldm0
1494109795
Apply rename suggestions
2021-02-07 05:32:35 +00:00
ldm0
fb3033834b
Change the way parser do self override
2021-02-07 04:46:56 +00:00
Donough Liu
58b9f35771
Add tests, fix grouped_values_of()
...
Fix clippy
type complexity fix
2021-02-07 04:46:56 +00:00
Donough Liu
451c5382cc
Finish arg grouping logic
2021-02-07 04:46:56 +00:00
Donough Liu
b48ccff812
Better MatchedArg::ty
2021-02-07 04:46:56 +00:00
Donough Liu
fdafa3f02a
More convenient MatchesArg functions
2021-02-07 04:46:56 +00:00
Donough Liu
7782a5eefc
Insert vals group for default missing vals
2021-02-07 04:46:56 +00:00
Donough Liu
32e03a0dfe
Better flow
2021-02-07 04:46:56 +00:00
Donough Liu
f1e9b82584
Implement nested vals
2021-02-07 04:46:56 +00:00
Donough Liu
9c52e454e8
Refactor MatchedArg::vals
2021-02-07 04:46:56 +00:00
Donough Liu
18549df845
Refactor MatchedArg::indices
2021-02-07 04:46:56 +00:00
ldm0
1000c9fb03
Fix eagerly trimming dash in parse_long_flag
2021-02-06 11:26:20 +00:00
Donough Liu
00cf697d36
Small simplification on several functions
2021-02-05 10:07:46 +00:00
Donough Liu
5e020c636d
Remove had_eq
2021-02-05 10:07:46 +00:00
Donough Liu
751adaa687
Remove ContainsLast flag
2021-02-05 10:07:46 +00:00
Donough Liu
818f62bd5c
Unused clippy allow
2021-01-30 17:39:34 +00:00
Donough Liu
45753d552b
Resolve a TODO
2021-01-30 17:39:34 +00:00
Donough Liu
cf4881182a
Add comments for some internal app settings
2021-01-30 17:39:34 +00:00
Donough Liu
c8e669c690
Eliminate unreachable branch
...
comment fix
Apply fmt
2021-01-30 17:39:33 +00:00
Donough Liu
944fc759c9
Optimize branch, more comments
2021-01-30 17:24:11 +00:00
Donough Liu
5774eb2c52
Simplify possible subcommand
2021-01-30 17:24:11 +00:00
Donough Liu
9cf007378b
Branch simpification
2021-01-30 17:24:11 +00:00
Donough Liu
336f926ec9
Integrate workflow
2021-01-30 17:24:11 +00:00
Donough Liu
be314d9ac0
Flow optimize
2021-01-30 17:24:11 +00:00
Donough Liu
c39dcf2ecf
Remove redundant ClapResult in some functions
2021-01-30 17:24:11 +00:00
Donough Liu
1b63516e3b
Flow reordering
2021-01-30 17:24:11 +00:00
Donough Liu
47eee8ab2f
Acc a request
2021-01-30 17:24:11 +00:00
Donough Liu
c6bcfe819e
Clearer error processing
2021-01-30 17:24:11 +00:00
Donough Liu
8f4c26fc58
Minor redundant logic cleanup
...
Fix clippy
dot fix
2021-01-30 17:24:09 +00:00
Pavan Kumar Sunkara
8d5a021e1e
Merge pull request #2309 from ldm0/parser0
...
Dehack, Revert #1856
2021-01-30 14:52:02 +00:00
ldm0
5ee6e07858
Fix usage of positional grouped arguments uses arg name rather than val_name
2021-01-24 19:02:43 +00:00
Donough Liu
0df169bbdc
Fix incorrect error message.
...
Comment out regressed logic
Fix clippy
2021-01-23 14:51:40 +00:00
Donough Liu
90d786b8bc
Dehack, revert #1856
2021-01-23 14:51:40 +00:00
Pavan Kumar Sunkara
d7f6748887
Merge pull request #2306 from ldm0/unset_setting
...
Fix unset_setting()
2021-01-23 13:37:57 +00:00
Bowen Ding
3907e11621
Make @group accept multiple attributes ( #2248 )
...
* Make @group accept multiple attributes.
* New syntax: remove parenthese and "=>".
* Fix example
* Make Clippy happy
* Make clippy happy again
2021-01-23 13:12:40 +00:00
ldm0
68a0ef930a
Fix copied code
2021-01-23 06:41:11 +00:00
AriusX7
448c102f4f
fix: allow visible alias(es) in yaml files
2021-01-20 02:17:17 +05:30
Pavan Kumar Sunkara
42a4087220
Merge pull request #2299 from ldm0/terminator
...
Pick up missing setting
2021-01-18 22:13:20 +00:00
Donough Liu
09f43594b9
Fix doc test
2021-01-19 02:39:16 +08:00
Donough Liu
acdb94c1a5
Add assert to make doc test fails.
2021-01-19 02:37:07 +08:00
Donough Liu
6968f340c3
Fix clippy warnings
2021-01-19 02:24:58 +08:00
Donough Liu
c6da968ec7
Bump textwrap to 0.13.2
2021-01-02 13:15:50 +08:00
Martin Geisler
72884b2642
docs: Mention correct default value in term_width docstring
...
The default was correctly changed to 100 in #1950 , but later
accidentally reverted in 89fcc75
.
2020-12-31 08:55:56 +01:00
Pavan Kumar Sunkara
a0269a41d4
Merge pull request #2268 from ldm0/fixme
...
Better mkeymap
2020-12-28 10:09:27 +00:00
Donough Liu
0f115f18ad
Fix positional count usage
2020-12-27 04:11:30 +08:00
Donough Liu
120e942e7a
Private arg
2020-12-27 01:46:48 +08:00
Donough Liu
2b7fd731ae
Private keys
2020-12-27 01:20:53 +08:00
Donough Liu
f54328ee4c
Cleaner api and better inner documentation
2020-12-27 00:43:49 +08:00
Donough Liu
53fdc9d6b2
Fix clippy
2020-12-26 21:03:21 +08:00
Donough Liu
ad3d3a13cd
KeyType: PartialEq for u64
2020-12-26 21:03:21 +08:00
Donough Liu
b2a066b24f
Resolve a fixme, better code readability
2020-12-26 21:03:21 +08:00
budde25
c26d1a4421
imp: added more derives to common App, Arg, and ArgMatches
2020-12-23 17:26:53 -06:00
budde25
52635f00d4
docs(arg_matches.rs): clarified unclear behavior for is_present and value_of methods
2020-12-23 07:44:19 -06:00
Pavan Kumar Sunkara
4bd15c45d2
Merge pull request #2253 from ldm0/global
...
Propagate global arg in subcommand to subsubcommand
2020-12-14 02:20:34 +00:00
Pavan Kumar Sunkara
c4ab996339
Merge pull request #2252 from ldm0/lazy_propagation
...
Lazy propagation and _build cleaning
2020-12-12 16:56:09 +00:00
Donough Liu
1965b9f866
Add BinNameBuilt flag to App
2020-12-13 00:11:12 +08:00
Donough Liu
2f9846d048
Lazy subcommand propagation, avoid redundant _build() function call
...
rustfmt and clippy
Indepth cleaning
Apply suggestions
2020-12-12 22:32:20 +08:00
Donough Liu
fa9be84b18
Propagate global arg in subcommand to subsubcommand
2020-12-12 22:20:16 +08:00
Donough Liu
5f5474d803
Fix only one arg printed in multiple required_unless missing situation
2020-12-12 12:57:17 +08:00
Donough Liu
6fdad97a90
Remove unused flag
2020-12-10 00:58:11 +08:00
Donough Liu
e58f89b3ab
Remove LowIndexMultiplePositional, stop repeatedly calc positional_count
2020-12-10 00:51:18 +08:00
Robin Moussu
6898fbde33
Automatically read license field from Cargo.toml
2020-12-09 00:16:19 +01:00
Donough Liu
573dc245e6
Fix incorrect error message.
2020-12-09 01:12:58 +08:00
Jonas Platte
041bfda7ca
Fix a typo in the Clap trait docs ( #2243 )
...
* Fix a typo in the Clap trait docs
* Update src/derive.rs
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-12-08 01:40:18 +00:00
Pavan Kumar Sunkara
3c93f276b5
Merge pull request #2230 from ahkrr/master
...
refactor: TODO 1.46.0, improve readability by using [] operator
2020-11-28 13:11:50 +00:00
Pavan Kumar Sunkara
c8184470ff
Merge pull request #2140 from ldm0/validator_fixme
...
Resolve a FIXME
2020-11-28 13:11:38 +00:00
Pavan Kumar Sunkara
b89163afb6
Update MSRV to 1.46
2020-11-28 11:58:28 +00:00
hk
bb7c9896b0
refactor: TODO 1.46.0, improve readability by using [] operator
2020-11-28 11:38:34 +01:00
Donough Liu
cad893ed04
Resolve a FIXME
2020-11-28 18:31:42 +08:00
arthmis
a97e24630d
chore: changing unrequired to non-required
2020-11-27 15:37:26 -05:00
arthmis
1b4a4596f6
docs: fixing a typo
2020-11-27 15:19:03 -05:00
arthmis
4e6a371851
chore: changing awkward grammar for positional argument error message
2020-11-27 15:12:28 -05:00
Pavan Kumar Sunkara
d36d91173d
Merge pull request #2191 from ahkrr/master
...
fix(clap_generate): zsh completion generation panic
2020-11-26 18:36:41 +00:00
Pavan Kumar Sunkara
821d79aac7
Merge pull request #1878 from lu-zero/update_from_arg_matches
...
Add update_from_arg_matches to FromArgMatches
2020-11-14 12:38:16 +01:00
Luca Barbato
3e51839383
Rename the update trait methods
2020-11-14 10:58:30 +01:00
Luca Barbato
5d342a7438
Update to the new from_subcommand logic
2020-11-14 10:17:13 +01:00
Luca Barbato
a9276576d7
wip: Add a variant for augment* for updates
2020-11-14 10:17:13 +01:00
Luca Barbato
8b6255057d
wip: Complete update_subcommand
...
external subcommand updating is equivalent to replace it
2020-11-14 10:17:13 +01:00
Luca Barbato
646b3fe811
wip: Add tests and user-facing functions
2020-11-14 10:17:13 +01:00
Luca Barbato
d1fc83a8fa
wip: Add update_from_arg_matches to FromArgMatches
2020-11-14 10:17:13 +01:00
hk
895c903b61
refactor: adding get_global, making two functions private
...
preserving the observable behavior of the existing
public api, while handling global arguments separately in
get_arg_conflicts_with
2020-11-09 15:29:00 +01:00
ldm0
ff3b23824d
Fix wrong StrictUTF8 handling when AllowExternalSubcommands
2020-11-08 19:06:32 +00:00
Donough Liu
93b9bd9162
Apply suggestions
2020-11-08 23:06:24 +08:00
Donough Liu
407cdac8e0
Refactor: remove a persistent parser state ValidNegNumFound
2020-11-08 16:05:07 +08:00
Donough Liu
3c2f60c9f3
Remove unreachable branch in use_long_arg()
2020-11-08 16:05:07 +08:00
Donough Liu
7aa2358d6e
Simplify is_new_arg()
2020-11-08 16:05:07 +08:00
Donough Liu
b1c7785810
Remove replace variable
...
Resolve TODO
Small refactors
More descriptive replaced item recovering
2020-11-08 16:05:03 +08:00
Donough Liu
5e4b4f4196
Remove invalid suggestion on using subcommand after positional argument
2020-11-07 20:32:28 +08:00
Donough Liu
2b1f47f975
Reduce osstring construction
2020-11-07 16:43:14 +08:00
Donough Liu
020b07b77b
Typo fix
2020-11-07 16:43:14 +08:00
Donough Liu
582db739c8
Shrink
2020-11-07 16:43:14 +08:00
Donough Liu
f17b29acbb
Make Arg::env()
and Arg::env_os()
takes_value(false)
by default
2020-11-06 21:51:39 +01:00
hk
5650e37969
fix: compatability with rustc 1.42.0
...
fixup!
2020-11-05 13:08:04 +01:00
hk
1b451f62ad
fix(clap_generate): zsh completion generation panic
...
zsh completion generation would panic if a global argument
had conflicts with another argument which was present in its
own command but not in its subcommands
2020-10-30 21:04:17 +01:00
bors[bot]
97b4fb639f
Merge #2165
...
2165: Help & Version settings r=pksunkara a=pksunkara
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-10-28 06:27:49 +00:00
Pavan Kumar Sunkara
5dd9584119
Improve the logic for help & version building & parsing
2020-10-26 12:13:03 +01:00
Donough Liu
a19bfa1c35
Consistently wrap help and subcommand messages(with refactoring)
2020-10-25 22:43:01 +01:00
KBR9
625c201f65
Add docs about conflicts_with_all usage in yaml
...
add note about conflicts_with yaml option
add note about conflicts_with yaml option
fix wrapping
remove unnecessary sentence
remove note from conflicts_with
2020-10-24 21:54:01 +02:00
Pavan Kumar Sunkara
e8a06e79cd
Rename setting VersionlessSubcommands => DisableVersionForSubcommands
2020-10-24 16:04:49 +02:00
Pavan Kumar Sunkara
d6e2246aab
Rename setting DisableVersion => DisableVersionFlag
2020-10-24 16:03:12 +02:00
Pavan Kumar Sunkara
45f0ee8b55
Rename setting DisableHelpFlags => DisableHelpFlag
2020-10-24 16:03:12 +02:00
CastilloDel
88ac1f1803
Add assertions for required and default simultaneously
...
Add the suggested changes
Fix test issue_1050_num_vals_and_defaults
It used a required which isn't needed for the purpose of the test.
Add tests for the default+required assertions
Add test for positional args with long or short
2020-10-24 12:10:07 +01:00
bors[bot]
1d0b21908f
Merge #2178
...
2178: Various documentation fixes r=pksunkara a=cstyles
Co-authored-by: Collin Styles <collingstyles@gmail.com>
2020-10-18 22:08:05 +00:00
Collin Styles
0d4e2e5f9d
docs: remove links in documentation for requires_all
...
These links were broken but rather than fix them, let's just remove them
since they're inside the documentation for the function that they link
to which seems unnecessary.
2020-10-18 12:05:33 -07:00
Collin Styles
5b74d84f3c
docs: remove links in documentation for requires_if
functions
...
These links were broken but rather than fix them, let's just remove them
since they're inside the documentation for the functions that they link
to which seems unnecessary.
2020-10-18 12:05:32 -07:00
Collin Styles
3d5e1d987a
docs: add a bunch of missing links to the docs for Arg::env
2020-10-18 12:05:31 -07:00
Collin Styles
ba89a253fc
docs: remove link to allow_hyphen_values
...
This link was broken but rather than fix it, let's just remove it since
it's inside the documentation for the function that it links to which
seems unnecessary.
2020-10-18 12:05:30 -07:00
Collin Styles
8522b9c1cf
docs: fix another typo and add a missing link for Last
2020-10-18 12:05:29 -07:00
Collin Styles
eadecc5c1d
docs: add missing link in ArgGroup
documentation
2020-10-18 12:05:28 -07:00
Collin Styles
096338d163
docs: correct typo in ErrorKind
documentation
2020-10-18 12:05:27 -07:00
Collin Styles
75c1fdb707
docs: fix various copy-paste errors related to default_value
functions
2020-10-18 12:05:26 -07:00
Collin Styles
f7837b2ac0
docs: change single quotes to backticks
...
Pretty sure these are just typos.
2020-10-18 12:05:25 -07:00
Collin Styles
9f3cbcd149
docs: wrap Arg in backticks instead of quotes
...
This looks better and is more consistent with the rest of the
documentation.
2020-10-18 12:05:22 -07:00
Collin Styles
b3caf81918
docs: fix a bunch of broken documentation links
2020-10-18 12:05:19 -07:00
CastilloDel
acd3293af2
Add an assertion for positional args defining long or short
...
Also update the docs to reflect that Arg.index shouldn't be
used with long or short
2020-10-18 19:51:13 +01:00
Jacob Mischka
b3e638ad44
Add option to hide autogenerated env section from help text
2020-10-17 16:48:35 -05:00
bors[bot]
d2dd54b555
Merge #2172
...
2172: Don't use default value when option is passed r=pksunkara a=davidhewitt
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2020-10-14 20:54:10 +00:00
David Hewitt
94f6889116
Don't use default value when option is passed
2020-10-14 20:00:40 +01:00
Wim Looman
b31df047b8
Attach validation error as Error::source
2020-10-13 22:13:04 +02:00
bors[bot]
5a1a209965
Merge #2161
...
2161: Fix parser skipping options without heading set r=pksunkara a=CertainLach
Co-authored-by: Yaroslav Bolyukin <iam@lach.pw>
2020-10-11 08:55:33 +00:00
Donough Liu
7f627fceee
Change MissingArgumentOrSubcommand to DisplayHelpOnMissingArgumentOrSubcommand and don't use stderr
2020-10-11 15:42:47 +08:00
bors[bot]
4f90f3e4bb
Merge #2166
...
2166: Sort options base on option's short and long representation r=ldm0 a=ldm0
Co-authored-by: Donough Liu <ldm2993593805@163.com>
2020-10-10 18:54:49 +00:00
Donough Liu
15c77150a9
Sort options base on option's short and long representation
2020-10-11 02:08:10 +08:00
Marti Raudsepp
cda89a2af1
Fix typos and grammar
...
Some more fixes in addition to 594c535ba2
* Some I noticed manually.
* Some were found by Topy (https://github.com/intgr/topy ), either new
rules from Typo or new code in clap.
* `etc.` and `e.g.` rules were disabled during the last run.
2020-10-10 16:22:05 +03:00
Donough Liu
c9a407aa54
Fix: Don't mention unused subcommands (Partly cherry pick ef92e2b
)
...
Add `\t` for consistency
2020-10-10 03:34:28 +08:00
bors[bot]
4ff4879400
Merge #2154
...
2154: Fix the error logic and error message for suggesting `--` before a flag r=pksunkara a=ldm0
Co-authored-by: Donough Liu <ldm2993593805@163.com>
2020-10-09 19:05:13 +00:00
Yaroslav Bolyukin
6050a17024
fix : #2022
...
Parser was skipping default values for options with headings
Signed-off-by: Yaroslav Bolyukin <iam@lach.pw>
2020-10-09 23:45:11 +05:00
Donough Liu
9766aa11b1
Remove redundant(wrong) error processing
...
Argument prefixed by `-` will never inferred as a subcommand
Suggest using subcommand when supplied after `--`
Cargo fmt, adding test for wrongly using subcommand after `--`
Fix test
Fix clippy
2020-10-10 00:06:50 +08:00
Donough Liu
5815246fd9
Fix the error logic and error message for suggesting -- before a flag
...
Fix tests
Add test for issue #1284
Apply nitpicks
2020-10-10 00:04:22 +08:00
Pavan Kumar Sunkara
8131ead04b
More changelog and consistency
2020-10-09 17:05:51 +02:00
Pavan Kumar Sunkara
b931e25c79
Update MSRV to 1.42
2020-10-09 17:04:46 +02:00
bors[bot]
91633741e9
Merge #2143
...
2143: api(App): Adds help_about method to App. r=pksunkara a=pretzelhammer
Co-authored-by: pretzelhammer <7769424+pretzelhammer@users.noreply.github.com>
2020-09-26 06:55:58 +00:00
pretzelhammer
523729d3fc
api(App): Adds version_about method to App.
...
Version about text is now customizable and propagates to subcommands. Closes #1640 .
2020-09-25 09:06:35 -04:00
bors[bot]
87c9699931
Merge #2135
...
2135: fix(help messages): escape values in help messages r=pksunkara a=ninewise
Co-authored-by: Felix Van der Jeugt <felix.vanderjeugt@posteo.net>
2020-09-25 09:16:05 +00:00
Felix Van der Jeugt
d5c7c7d8bd
Fix clippy errors
2020-09-25 10:38:35 +02:00
pretzelhammer
33caf49793
api(App): Adds help_about method to App.
...
Help about text is now customizable and propagates to subcommands. Closes #2080 .
2020-09-24 17:53:02 -04:00
Felix Van der Jeugt
a083953d3a
Suggest corrections with double quotes
2020-09-24 17:58:35 +02:00
Pavan Kumar Sunkara
99b8830d0b
Remove unneeded cfg_attr
2020-09-24 13:51:02 +02:00
Pavan Kumar Sunkara
d881a1185b
Release 3.0.0-beta.2
...
clap@3.0.0-beta.2
clap_derive@3.0.0-beta.2
clap_generate@3.0.0-beta.2
Generated by cargo-workspaces
2020-09-18 20:32:41 +02:00
Felix Van der Jeugt
0f42344685
fix(help messages): escape whitespace values in help messages
2020-09-16 15:51:33 +02:00
bors[bot]
03c11607b5
Merge #2132
...
2132: Add missing links in docs. r=pksunkara a=newAM
Co-authored-by: Alex M <alexmgit@protonmail.com>
2020-09-12 18:28:23 +00:00
Alex M
96db338697
Add missing links in docs.
2020-09-12 10:15:14 -07:00
Alex M
3758725dc2
Fix for issue #2130 .
2020-09-12 09:52:52 -07:00
bors[bot]
3e9ee86713
Merge #2118
...
2118: Rename r=CreepySkeleton a=pksunkara
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-08-29 11:22:13 +00:00
bors[bot]
61786c4971
Merge #2117
...
2117: Remove useless code r=pksunkara a=CreepySkeleton
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-08-29 10:58:07 +00:00
Pavan Kumar Sunkara
55abd639f7
Rename get_*_no_heading to get_*_with_no_heading
2020-08-29 11:49:04 +02:00
Pavan Kumar Sunkara
9e381f92a9
Rename required_unless_eq_* to required_unless_present_*
2020-08-29 11:48:35 +02:00
CreepySkeleton
ccb1ea2d65
Remove useless code
...
This code does not serve any purpose as far as I can tell
2020-08-29 00:44:11 +03:00
CreepySkeleton
3a099a6627
Implement std::error::Error for clap::Error
2020-08-28 20:57:39 +03:00
bors[bot]
e4b5407296
Merge #1976 #2073
...
1976: Refactor r=pksunkara a=CreepySkeleton
2073: Add new "regex" feature r=CreepySkeleton a=bkaestner
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
Co-authored-by: Benjamin Kästner <benjamin.kaestner@gmail.com>
2020-08-28 17:14:31 +00:00
CreepySkeleton
5020333037
Refactor coloring
2020-08-28 19:21:05 +03:00
Benjamin Kästner
cde1a2d218
regex: Introduce convenience Cow-wrapper RegexRef
...
As previously discussed on [GitHub], this commit introduces a Cow-like
wrapper RegexRef to enable both `Regex` as well as `&Regex` as
arguments.
It also introduces a new module in the `build:arg` path to remove
clutter from the main module. For more information see #2073 .
[GitHub]: https://github.com/clap-rs/clap/pull/2073#issuecomment-674442310
2020-08-26 17:54:54 +02:00
Benjamin Kästner
8cb9a7d486
Add new "regex" feature
...
This commit introduces a new feature called `"regex"`. It adds a new
function `validator_regex` to `Arg` and was inspired by the discussion
in #1968 . The name `validator_regex` was chosen instead of
`regex_validator` to make sure that the developer keeps in mind that
there may only be a single `Validator` on an `Arg`.
The feature can be used with YAML files, however there is no proper
pattern in `clap_app!` (yet).
2020-08-26 17:54:54 +02:00
Sergey Dubovyk
d525be42c5
chore: use if instead of matching
...
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-08-25 11:07:19 +03:00
knidarkness
530b179776
fix: detect if space should be added before spec_vals
2020-08-25 10:41:08 +03:00
bors[bot]
29df5c2d16
Merge #2100 #2106
...
2100: Allow for nested subcommands with ZSH generation. r=pksunkara a=newAM
2106: Update the env var example for derive r=pksunkara a=rgreinho
Co-authored-by: Alex M <alexmgit@protonmail.com>
Co-authored-by: Rémy Greinhofer <remy.greinhofer@gmail.com>
2020-08-24 06:45:45 +00:00
bors[bot]
7853903052
Merge #2102
...
2102: Fix propagation r=pksunkara a=CreepySkeleton
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-08-24 06:22:27 +00:00
CreepySkeleton
1cd069090e
Fix propagation
2020-08-23 20:56:29 +03:00
Alex M
60dfcf13b5
Allow for nested subcommands with ZSH generation.
2020-08-23 09:33:29 -07:00
Simon Morgan
2e973a2649
Fix a few documentation typos
2020-08-22 16:49:09 +01:00
CreepySkeleton
28ad25fe66
Ensure the lifetime is 'static
2020-08-21 08:41:50 +03:00
CreepySkeleton
fd1ee7872e
Make caching in crate_authors! actually work
2020-08-21 08:21:21 +03:00
bors[bot]
ed3bb993c5
Merge #2087
...
2087: refactor: Avoid second traversal and unwrap r=pksunkara a=phimuemue
Co-authored-by: philipp <descpl@yahoo.de>
2020-08-21 03:56:53 +00:00
aspen
96b7fd454b
Forbid all unsafe code.
2020-08-20 18:38:40 -04:00
philipp
86dc14f5cd
refactor: Avoid second traversal and unwrap
2020-08-20 19:32:53 +02:00
Danil Kondratiev
4878f7b7b1
don't print spaces in long help
2020-08-20 17:25:36 +03:00
bors[bot]
1e3d53fd1f
Merge #2081
...
2081: Polish doc comments for App r=CreepySkeleton a=mkantor
Co-authored-by: Matt Kantor <the.matt.kantor@gmail.com>
2020-08-17 20:56:13 +00:00
bors[bot]
025ec3c28b
Merge #2078
...
2078: Unify naming cheme r=pksunkara a=CreepySkeleton
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-08-17 20:35:05 +00:00
Matt Kantor
f6e28c5ff0
Remove doc mention of no-longer-existing from_yaml method.
2020-08-17 12:54:24 -07:00
Matt Kantor
494fddd06e
Polish doc comments for App.
...
- Fix some links.
- Make the punctuation consistent.
- Correct some spelling/grammar mistakes.
2020-08-17 11:00:00 -07:00
tomjw64
27771ceeb7
Show arguments in conflict message in reverse order of input
2020-08-16 03:47:19 -05:00
tomjw64
97149e37f5
Remove underscore prefix for build_conflict_err_usage
2020-08-16 03:42:58 -05:00
tomjw64
35f761e699
Extract extra logic to _build_conflict_err_usage
2020-08-15 17:58:47 -05:00
CreepySkeleton
f4fb9db65c
cargo fmt
2020-08-16 00:29:30 +03:00
CreepySkeleton
0b2eac4da7
Fix yaml support
2020-08-15 23:42:23 +03:00
CreepySkeleton
ce3171ace5
Arg::required_unless_all => required_unless_eq_all
2020-08-15 20:38:57 +03:00
CreepySkeleton
b12102c832
Arg::required_unless -> required_unless_present
2020-08-15 20:38:56 +03:00
CreepySkeleton
55dceca819
Improve documentation
2020-08-15 20:38:56 +03:00
CreepySkeleton
233af6e7a1
Arg::required_if => required_if_eq
2020-08-15 20:38:55 +03:00
CreepySkeleton
8b85c4ecea
Arg::required_ifs => required_if_eq_any
2020-08-15 20:38:12 +03:00
CreepySkeleton
6b6b6035ed
Arg::required_unless_one => required_unless_eq_any
2020-08-15 20:38:11 +03:00
tomjw64
481229fffd
Remove stray print
2020-08-15 04:49:53 -05:00
tomjw64
826db05319
Add test for three argument conflict output
2020-08-15 04:43:12 -05:00
tomjw64
6602feb9e6
Also include required arguments in conflict output
2020-08-15 04:17:28 -05:00
tomjw64
937e14f6e8
Remove latter conflicting arg from usage message
2020-08-15 03:17:16 -05:00
bors[bot]
26aa746c3a
Merge #2067
...
2067: Use a template to produce the default help message r=pksunkara a=mkantor
Co-authored-by: Matt Kantor <the.matt.kantor@gmail.com>
2020-08-14 23:42:38 +00:00
Matt Kantor
85d3daa8c1
Use a different default template when there are no args.
...
This eliminates extraneous empty lines when there are no user-defined
args, the default args are disabled, and `after_help` is set.
2020-08-14 14:02:52 -07:00
Matt Kantor
4545a47ff6
Fix: {before-help} should have fallback just like {after-help}.
2020-08-14 13:58:37 -07:00
Benjamin Kästner
2b101ad7e5
Properly handle YAML null macros for default_value_if
...
The macro `yaml_opt_str` is only used in `yaml_tuple3`, which again is
only used for `default_value_if`. Unfortunately, the current test
doesn't make sense, as a v.is_null() indicates a Yaml::Null, on wich
`as_str()` always returns `None`. Instead, the condition should be
negated, as the documentation of `default_value_if` hints:
> **NOTE:** If using YAML the values should be laid out as
> follows (`None` can be represented as `null` in YAML)
The case `$v.is_null()` should therefore lead to `None`, whereas all
other cases should be interpreted `as_str()`.
2020-08-14 18:28:43 +02:00
Matt Kantor
2c91800099
Restore details to doc comment for help_template.
2020-08-14 09:27:42 -07:00
Matt Kantor
afcacb0626
Apply wrapping to {author} and {about} template tags.
...
Previously wrapping was only applied to the {*-with-newline} variants.
2020-08-14 09:14:14 -07:00
Matt Kantor
059503e54d
Make {before-help} and {after-help} template tags include padding.
...
Previously there were separate tags for this, {before-help-padded} and
{after-help-padded}. Those have been removed and the default ones
given their behavior.
2020-08-14 09:14:10 -07:00
Matt Kantor
a87320ae88
Use a template to produce the default help message.
...
This makes some changes to the template system:
- Template tags for optional items (like {author}) now expand to
nothing when the value is unset instead of a default string (like
"unknown author").
- Many template tags now emit line-wrapped output to match
write_default_help.
- Items with long variants now expand to the appropriate thing for -h
vs --help.
- The now-obsolete {long-about} tag has been removed.
- A few new tags have been added.
These are externally-visible changes, but if this makes it into 3.0
that's probably reasonable?
Note that line-wrapping can have some odd edge cases since it does not
account for preceding/trailing characters on the same line as the tag.
This is already the case in master, but will affect some additional
tags with this changeset. See #2065 for details.
Closes #2002 .
2020-08-13 17:52:48 -07:00
bors[bot]
ca6c84fa8a
Merge #1961
...
1961: V3 docs r=CreepySkeleton a=pksunkara
Co-authored-by: Kevin K <kbknapp@gmail.com>
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-08-12 14:58:09 +00:00
bors[bot]
2df656c98d
Merge #1998
...
1998: Relax some restrictions on validators r=pksunkara a=CreepySkeleton
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-08-12 14:35:39 +00:00
Pavan Kumar Sunkara
c2e3b719ae
Apply suggestions from code review
...
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-08-12 15:50:15 +02:00
CreepySkeleton
39fadbf7c8
Rebase
2020-08-12 16:40:19 +03:00
CreepySkeleton
32414fbdff
Fix and rearrange debug asserts
2020-08-12 06:12:42 +03:00
CreepySkeleton
18a58af3ac
Allow validators to be FnMut
2020-08-12 02:39:59 +03:00
CreepySkeleton
790a0f5e62
Make sure that App & Arg & ArgGroup implement Send + Sync
...
Also relaxes 'static restriction on validators.
2020-08-12 02:39:59 +03:00
Matt Kantor
0d8ebeb36b
Fix doc comment for Arg::long_about.
2020-08-11 15:30:30 -07:00
Matt Kantor
f7e2fbf150
Print an empty line after multi-line argument help.
...
Fixes #1642 .
2020-08-11 15:30:30 -07:00
Pavan Kumar Sunkara
5c0947f160
Add derive traits only if derive feature is enabled
2020-08-11 16:30:02 +02:00
Pavan Kumar Sunkara
9b22f19995
Update more docs
2020-08-11 16:08:05 +02:00
Kevin K
89fcc755e4
wip: doc updates for App
...
Still more to do in this file, hence the wip status
2020-08-11 15:41:00 +02:00
Kevin K
aa694c893f
docs(FromArgMatches): initial draft
2020-08-11 15:21:58 +02:00
Kevin K
763f0a0363
wip: Clap trait docs
2020-08-11 15:21:57 +02:00
bors[bot]
da92a32d10
Merge #2048
...
2048: Change the ret tyte of Argmatches::subcommand r=pksunkara a=CreepySkeleton
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-08-11 00:20:35 +00:00
Marti Raudsepp
64ee0f8009
Add hinting of arg value types for zsh/fish completion
...
Adds new method/attribute `Arg::value_hint`, taking a `ValueHint` enum
as argument. The hint can denote accepted values, for example: paths,
usernames, hostnames, commands, etc.
This initial implementation supports hints for the zsh and fish
completion generators, support for other shells can be added later.
2020-08-06 22:17:31 +03:00
CreepySkeleton
e6cc49ecde
Adjust derive
2020-08-05 17:07:13 +03:00
CreepySkeleton
e9759a241b
Adjust examples and tests
2020-08-05 17:07:13 +03:00
CreepySkeleton
6dcf93be00
Change the return type of ArgMatches::subcommand()
2020-08-05 13:35:42 +03:00
Nicholas Nethercote
ed46e8962c
refactor: Combine two large and very similar expressions.
2020-07-29 10:35:36 +10:00
Nicholas Nethercote
7fb397d905
refactor: Simplify some it.any(...)
calls.
2020-07-29 10:35:34 +10:00
Nicholas Nethercote
be535e28cf
refactor: Avoid unnecessary uses of enumerate()
.
2020-07-29 10:35:31 +10:00
Nicholas Nethercote
d8c775eb26
refactor: Replace it.filter(...).find(...)
with it.find(...)
.
2020-07-29 10:35:27 +10:00
bors[bot]
dbdd63b350
Merge #2016
...
2016: imp(errors): Provide the missing required arguments as info r=CreepySkeleton a=nickelc
Co-authored-by: Constantin Nickel <constantin.nickel@gmail.com>
2020-07-26 08:08:35 +00:00
bors[bot]
dda961b715
Merge #2027
...
2027: style: rename ErrorKind::{VersionDisplayed, HelpDisplayed} to present tense r=CreepySkeleton a=siyopao
Co-authored-by: Craig Pastro <siyopao@gmail.com>
2020-07-26 07:36:52 +00:00
CreepySkeleton
37c1631f06
Make lifetimes descriptive
2020-07-21 18:59:07 +03:00
bors[bot]
1d57aa2ffb
Merge #2030
...
2030: style: replacing yml with yaml for consistency r=pksunkara a=marcospb19
Co-authored-by: João Marcos <marcospb19@hotmail.com>
2020-07-21 13:11:15 +00:00
bors[bot]
aab97614ed
Merge #2020
...
2020: Implementation of feature request #1918 r=pksunkara a=leo-lb
Co-authored-by: Léo Le Bouter <lle-bout@zaclys.net>
2020-07-21 09:47:23 +00:00
João Marcos
24760bc261
style: replacing yml with yaml for consistency
2020-07-20 20:58:34 -03:00
Léo Le Bouter
eabe8b67b4
Implementation of feature request #1918
2020-07-20 15:35:40 +02:00
Craig Pastro
866f2edbed
style: rename ErrorKind::{VersionDisplayed, HelpDisplayed} to present tense
2020-07-20 10:27:07 +09:00
Blaxar Waldarax
748aea39f3
feat: Added {before/after}_help_long to App struct, closed #1903
2020-07-19 13:59:53 +02:00
Marti Raudsepp
594c535ba2
Fix various typos in docs & code
...
Most errors detected and fixed with Topy (https://github.com/intgr/topy ),
all verified by hand.
2020-07-19 03:10:28 +03:00
bors[bot]
ff6beebd6e
Merge #1974
...
1974: Flag subcommands r=CreepySkeleton a=NickHackman
Co-authored-by: NickHackman <snickhackman@gmail.com>
Co-authored-by: Nick Hackman <31719071+NickHackman@users.noreply.github.com>
2020-07-18 14:06:50 +00:00
NickHackman
6c6b9db45c
fix: clippy lint warning - name change
...
Lint name changed clippy::block_in_if_condition_stmt -> clippy::block_in_if_conditions
2020-07-16 18:05:25 -04:00
NickHackman
21436398a2
docs: improved flag subcommand documentation
...
Improved documentation in flag subcommand example and in
`App::short_flag` and `App::long_flag` method documentation.
2020-07-16 17:48:00 -04:00
Constantin Nickel
6fe48fd51f
imp(errors): Provide the missing required arguments as info
2020-07-15 00:52:06 +02:00
Constantin Nickel
fbfbf8df99
feat(macros): Add @global_setting $setting
to set global settings
2020-07-13 15:13:04 +02:00
NickHackman
0ddd58c935
fix: clippy lint warning
...
Not necessary to borrow the to_string for comparison
2020-07-11 15:21:53 -04:00
NickHackman
6ddf940ac3
fix: conflicts between flag scs and args alias
...
When debug_assertions flag is active, properly handles conflicts between
flag subcommands short and long their aliases and args and their
aliases prevents self conflicts where the alias and the flag subcomand
were the same.
2020-07-11 15:01:18 -04:00
NickHackman
cf9265d660
fix: failing doc test
2020-07-10 09:36:39 -04:00
NickHackman
5118cec1b1
fix: long_flag_aliases instead of using alias
...
Previously long_flag alias checks were against normal aliases instead of
specifically designated long_flag aliases, this is more clear and explicit.
2020-07-10 09:27:14 -04:00
NickHackman
f5aabfa482
style: rename short, long -> short_flag, long_flag
...
These names are more explicit about what short and
long flag subcommands are.
2020-07-10 08:52:13 -04:00
bors[bot]
d8fccdb0ea
Merge #1986
...
1986: Custom subcommand placeholders r=pksunkara a=kitlith
Co-authored-by: Kitlith <kitlith@kitl.pw>
2020-07-10 12:51:30 +00:00
bors[bot]
608b982bbe
Merge #1997
...
1997: Cleanup setings r=pksunkara a=CreepySkeleton
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-07-10 09:53:47 +00:00
NickHackman
0a266f8c8c
fix: merge related issues
...
get_subcommands() now returns an impl Iterator rather than a slice,
match_alias! removed
2020-07-09 22:15:48 -04:00
Nick Hackman
27441329f9
Merge branch 'master' into flag-subcommands
2020-07-09 21:31:13 -04:00
NickHackman
a3f8ddb0b0
doc: removed '[``]' from documentation
2020-07-08 21:46:00 -04:00
NickHackman
1127ca6e13
feat: Usage displays short, long, and normal scs
...
Displayed in the form of
pacman {query, --query, -Q} [OPTIONS]
2020-07-08 21:37:56 -04:00
NickHackman
ec35ab8813
feat: long flag subcommand infer
...
Added tests and feature to infer long flag subcommands similarly to
normal subcommands.
2020-07-08 00:11:28 -04:00
NickHackman
1ea7178629
refractor: find_*_subcmd macro -> fn
...
Moved from macro implementations to function implementations.
2020-07-07 22:57:38 -04:00
NickHackman
59a14f8e6a
fix: no longer cloning all Apps and Args for debug
...
Previously `Flag::App` and `Flag::Arg` both owned their App/Arg which
required many, many clones. This is unnecessary.
2020-07-07 22:36:12 -04:00
NickHackman
5db25e6a72
refractor: improved parser ergonomics
...
No longer abusing external_subcommand, but using subcmd_name in order to
parse a subcommand, added a `keep_state` variable in order to handle the
hacky solution of short command line arguments.
2020-07-07 22:26:44 -04:00
Kitlith
96daa203b9
cargo fmt
2020-07-07 00:23:00 -07:00
Kitlith
5f601b7ecd
Manually specify the header for subcommands.
...
Also fleshed out the documentation for subcommand_placeholder a bit.
2020-07-06 20:08:26 -07:00
bors[bot]
e8d46f4036
Merge #1989
...
1989: Replace macros with proper functions r=pksunkara a=CreepySkeleton
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-07-06 18:51:07 +00:00
CreepySkeleton
7e8d120543
Make getters return iterators rather than slices
2020-07-06 17:33:02 +03:00
CreepySkeleton
46679d88d6
Use method(bool) instead of manipulating ArgSettings explicitly
2020-07-02 05:42:28 +03:00
CreepySkeleton
b23890358a
Remove ArgSettings::UseValueDelimiter
2020-07-02 05:02:28 +03:00
Pavan Kumar Sunkara
e68ec35a90
Move to terminal_size dep after the recent textwrap upgrade
2020-07-01 09:46:10 +02:00
Kitlith
6d083f5653
imp(subcommands): "SUBCOMMANDS" label affected by subcommand placeholder
2020-06-27 14:21:17 -07:00
CreepySkeleton
a3206197ff
cargo clippy + fmt
2020-06-27 04:30:02 +03:00
CreepySkeleton
f904bebd9a
Ditch find_subcnd*! and match_alias!
2020-06-27 04:30:02 +03:00
CreepySkeleton
f143b2f70e
Ditch names! and sc_names!
2020-06-27 04:30:02 +03:00
CreepySkeleton
a9b022d777
Ditch longs!
2020-06-27 04:30:02 +03:00
CreepySkeleton
270fd55f60
Ditch groups_for_arg!
2020-06-27 04:30:02 +03:00
CreepySkeleton
b7be22e90b
Ditch opts! and positionals!
2020-06-27 04:30:01 +03:00
CreepySkeleton
f46af5b96b
Ditch flags!
2020-06-27 04:30:01 +03:00
Kitlith
3d406400ec
Allow changing the "SUBCOMMAND" placeholder text in usage ( #1597 )
2020-06-25 17:27:25 -07:00
Kamil Ogórek
ef162afd4b
Removed word duplicate from docs for allow_hyphen_values
2020-06-22 16:52:27 +02:00
NickHackman
b09afcf653
fix: Gate fmt::Display
for Flag w/ debug_asserts
...
Implementation of `fmt::Display` for `Flag` caused tests to fail when
not ran with `debug_assertions` feature.
2020-06-17 00:09:25 -04:00
NickHackman
bf3d947f01
fix: Flag Subcommands conflicts panic
...
Conflicts with Flag subcommands and Args now panics when
`debug_assertions` is enabled, rather than causing bizarre behavior.
2020-06-16 23:45:21 -04:00
NickHackman
02ebf4f816
fix: display visible short flags, visible flags
...
Flags weren't being set as visible in one instance. Flags were not being
printed in help message.
2020-06-16 01:13:58 -04:00
NickHackman
acb2f755f8
api: short_flag_aliases and corresponding methods
...
Aliases exclusively for `App::short_flag` that allow visible and hidden
short flag subcommands.
2020-06-16 00:13:21 -04:00
NickHackman
458736bee8
imp: Improved Flag Subcommand API
...
Instead of a `FlagSubCommand` struct the addition of two simple methods
to `App`. `App::long_flag` and `App::short_flag` that cover all the
bases of the many methods that were provided in `FlagSubCommand`. This
API is far simpler to use and more akin to the present `Arg::long` and `Arg::short`.
2020-06-15 21:52:36 -04:00
NickHackman
a9091d141c
chore: removed debug print
...
Removed a `debug!` line that referenced me.
2020-06-13 18:02:05 -04:00
NickHackman
0b179fe8ef
api: FlagSubCommand, subcommand flags #1361
...
Adds support for Flag subcommands, for example:
$ pacman -Ss
$ pacman --sync -s
2020-06-13 17:40:09 -04:00
bors[bot]
81457178fa
Merge #1972
...
1972: Newline bug r=pksunkara a=stedingan
Co-authored-by: Andreas Steding <steding.andreas@gmail.com>
2020-06-10 19:32:52 +00:00
Andreas Steding
abef54862d
changed write!() to writeln!() to add a newline
2020-06-10 15:35:54 +02:00
bors[bot]
055568d3fe
Merge #1964
...
1964: Updated Changelog and added the upgrader r=CreepySkeleton a=pksunkara
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-06-10 10:22:58 +00:00
bors[bot]
d149999413
Merge #1967
...
1967: Reexport Indices r=pksunkara a=CreepySkeleton
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-06-10 07:38:57 +00:00
Pavan Kumar Sunkara
1a276f8f4f
Remove Arg::help
2020-06-10 09:34:55 +02:00
bors[bot]
d67c3bb7d3
Merge #1970
...
1970: refactor: removed clap_count_exprs macro r=pksunkara a=stedingan
Co-authored-by: Andreas Steding <steding.andreas@gmail.com>
2020-06-10 06:59:00 +00:00
Andreas Steding
294beff930
refactor: removed clap_count_exprs macro
2020-06-10 08:27:36 +02:00
CreepySkeleton
24ed93daae
Reexport Indices
2020-06-09 08:39:07 +03:00
Andreas Steding
7bc0fed82e
fix: Corrected assertion arguments
2020-06-08 14:30:11 +02:00
Artem Vorotnikov
fc8a0bba9c
Make App's help heading a priority, optimize it
2020-06-01 08:39:58 +03:00
Artem Vorotnikov
2de5c0e44c
Fix custom help headings
2020-06-01 07:42:07 +03:00
CreepySkeleton
41c4d186f1
Fix warnings
2020-05-31 17:53:24 +03:00
CreepySkeleton
12e8541678
Remove pointless test
...
Come on, who on earth needs to test exact content of debug output?!
2020-05-31 03:27:44 +03:00
CreepySkeleton
f1479974e0
Proper debug in ArgGroup
2020-05-31 01:32:50 +03:00
CreepySkeleton
d6603c739d
Limit text wrapping to 100 symbols by default
2020-05-30 19:34:48 +03:00
bors[bot]
9af127a4f4
Merge #1949
...
1949: docs: correct some typos r=pksunkara a=goncalor
Co-authored-by: Gonçalo Ribeiro <darklaw13@yahoo.co.uk>
2020-05-30 10:36:45 +00:00
Gonçalo Ribeiro
fb8e0d815d
docs: correct some typos
2020-05-30 11:14:47 +01:00
Ivan Tham
270f9ce37f
Update src/build/arg/mod.rs
...
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-05-25 21:06:22 +08:00
Ivan Tham
a189770e1c
Fix Arg::required doc examples
2020-05-25 21:00:17 +08:00
CreepySkeleton
a827ad5bd4
Use proper fmt::DebugStruct facility in Debug impl
2020-05-23 20:08:04 +03:00
meltinglava
2096777022
fixed spacing in error messages
2020-05-23 13:10:14 +02:00
Roy Ivy III
83a822e101
docs ~ add documentation for new 'default_missing_value' configuration option
2020-05-21 13:08:39 -05:00
Roy Ivy III
98b5d49647
add 'default_missing_value' configuration option
2020-05-21 13:05:25 -05:00
dave
2a023b226c
chore: fix typo in comment
2020-05-20 22:12:45 +02:00
CreepySkeleton
5589276093
Rename App::set_term_width to term_width
...
None of the other methods that move self have the `set_` prefix
2020-05-18 12:46:14 +03:00
Patrick Marks
4a9e01b0bc
ensure that validation failure error message includes a newline. also add a basic test of a failed validation
2020-05-17 08:50:35 -07:00
bors[bot]
961ed9cfdd
Merge #1931
...
1931: Allow separate derives, but do not give examples r=CreepySkeleton a=pksunkara
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-05-16 02:18:48 +00:00
Patrick Marks
97e3d8c0ac
fix some cases of the 'The following required arguments were not provided' error message
2020-05-15 07:58:57 -07:00
Pavan Kumar Sunkara
aab2e41f8a
Consistent From<Yaml> for ArgGroup
2020-05-15 13:59:31 +02:00
Pavan Kumar Sunkara
fe52d77f4e
Allow separate derives, but do not give examples
2020-05-15 09:51:42 +02:00
Pavan Kumar Sunkara
7bc282dd4e
Rename with_name to new for Arg & ArgGroup
2020-05-14 22:50:56 +02:00
bors[bot]
65e6f08517
Merge #1926
...
1926: refactor: Implement From<Yaml> on Arg and ArgGroup r=pksunkara a=lanesawyer
Co-authored-by: Lane Sawyer <github@lanesawyer.dev>
2020-05-14 08:47:37 +00:00
Lane Sawyer
1ba04346ff
refactor: Implement From<Yaml> on Arg and ArgGroup
2020-05-13 19:04:53 -07:00
Pruthvikar Reddy
28ffa721ab
Fix typos
2020-05-13 21:58:50 +01:00
bors[bot]
aa6110268a
Merge #1911
...
1911: Option vec to vec r=pksunkara a=CreepySkeleton
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-05-13 09:42:49 +00:00
CreepySkeleton
5004fa218f
cargo clippy
2020-05-13 09:48:33 +03:00
CreepySkeleton
fed5c6787b
Fix tests
2020-05-13 05:53:17 +03:00
CreepySkeleton
6810889879
Turn Option<Vec<T>> into Vec<T>
2020-05-13 05:53:17 +03:00
Pavan Kumar Sunkara
cfb0e95c9e
Fix some stuff
2020-05-12 10:39:24 +02:00
Kevin Tonon
0b58088781
Fix clap_app! usage example
...
I found this usage example confusing because `matches` was actually an `App`
2020-05-12 00:58:41 +02:00
Charles Hall
1019724026
setting(DisableHelpFlags): disable the automatic generation of the -h/--help flags
2020-05-12 00:55:49 +02:00
Peter Corlett
719161ebba
fix(macros): fixes broken pattern which prevented calling multi-argument Arg methods
2020-05-12 00:45:32 +02:00
Windfarer
2b2dbbc506
adding case_insensitive to yaml parsing
2020-05-12 00:36:47 +02:00
Ivan Tham
9849430b11
style: group example
2020-05-12 00:32:52 +02:00
Felix Rabe
3ea552bfe2
Typo
2020-05-12 00:30:58 +02:00
raffitz
b1b31c3ab7
Add long_version support in YAML parsing
2020-05-12 00:30:48 +02:00
bors[bot]
33c63c6e29
Merge #1901
...
1901: implement Arg::short_alias and Arg::short_aliases r=pksunkara a=connorskees
Co-authored-by: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com>
2020-05-11 16:03:51 +00:00
ConnorSkees
59f3e9414b
allow short aliases on Arg
...
this implements Arg::short_alias, Arg::short_aliases,
Arg::short_visible_alias, and Arg::short_visible_aliases in addition to
adding their associated tests
2020-05-11 11:21:01 -04:00
Pavan Kumar Sunkara
cc32c03055
Minor fix for the README
2020-05-11 11:15:59 +02:00
bors[bot]
8f98a329da
Merge #1715
...
1715: Update README for beta release r=kbknapp a=pksunkara
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-05-03 07:09:49 +00:00
bors[bot]
2ba7816c9e
Merge #1894
...
1894: Eradicate warnings r=pksunkara a=CreepySkeleton
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-05-03 06:50:57 +00:00
CreepySkeleton
2eebd76a04
Eradicate warnings: main codebase
2020-05-02 23:33:43 +03:00
Pavan Kumar Sunkara
a67d1d7a40
Update README for beta release
2020-05-02 22:27:42 +02:00
dylni
99096ecbe9
Handle more edge cases for an ArgStr
prefix
2020-05-01 18:19:40 -04:00
bors[bot]
99e862945e
Merge #1883
...
1883: External subcommand r=pksunkara a=CreepySkeleton
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-05-01 17:59:32 +00:00
bors[bot]
93dd22c2f9
Merge #1890
...
1890: fix(build/app): don't use long help for `print_help() r=kbknapp a=cole-h
Co-authored-by: Cole Helbling <cole.e.helbling@outlook.com>
2020-05-01 15:57:11 +00:00
Cole Helbling
2bc057eaa5
fix(build/app): don't use long help for print_help()
...
For long help, there's still `print_long_help()`.
2020-05-01 08:01:26 -07:00
CreepySkeleton
6bdb6d9b2e
Marry AllowExternalSubcommands with SubcommandRequiredElse*
2020-05-01 15:33:36 +03:00
CreepySkeleton
ec6b6e1e36
Make validator take &str instead of String
2020-05-01 14:21:11 +03:00
CreepySkeleton
ee463ba834
Make extrernal_subcommand
ALMOST work
2020-04-30 20:20:21 +03:00
CreepySkeleton
7a7148d087
Make struct SubCommand
private
2020-04-29 21:34:59 +03:00
bors[bot]
5b9dbee5db
Merge #1876
...
1876: Allow usage of deprecated arg::help in yaml r=CreepySkeleton a=pksunkara
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-04-28 11:39:05 +00:00
Pavan Kumar Sunkara
20d6b01818
Allow usage of deprecated arg::help in yaml
2020-04-28 12:37:52 +02:00
Pavan Kumar Sunkara
348744ab04
Rename some internal stuff
2020-04-28 11:13:09 +02:00
CreepySkeleton
4812cf2101
Make sure output is always flushed before exiting
2020-04-27 21:47:33 +03:00
CreepySkeleton
c6fdd3a7ce
Reshape imports
2020-04-27 21:47:08 +03:00
creativcoder
d0abb378b0
cargo fmt
2020-04-27 20:41:41 +05:30
creativcoder
35fdb45adb
Update bench tests with about and add inline to about methods
2020-04-27 20:00:36 +05:30
creativcoder
266dbbe3f4
Code review p2
2020-04-27 19:37:17 +05:30
creativcoder
92d5920748
Updated test and usage of older help APIs with about
2020-04-27 02:42:07 +05:30
creativcoder
75f5a9ab62
Code review p1
2020-04-27 02:42:07 +05:30
creativcoder
24cb8b13c5
Deprecate Arg::help in favour of Arg::about
2020-04-27 02:42:07 +05:30
CreepySkeleton
312432a5db
Fix a bug we didn't know about
2020-04-26 21:16:14 +03:00
CreepySkeleton
c9e03e7e67
Default values trigger conflicts no more ( #1605 )
2020-04-26 21:16:09 +03:00
CreepySkeleton
02fac2315f
Add hide_default_values to yaml
2020-04-26 13:47:53 +03:00
CreepySkeleton
3e865e565f
A little cleanup
2020-04-25 15:57:12 +03:00
CreepySkeleton
2403ae796e
Apply suggestions from code review
...
Co-Authored-By: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-04-24 23:06:13 +03:00
CreepySkeleton
756e95388f
Remove _StrExt
2020-04-24 22:47:55 +03:00
CreepySkeleton
f69ec92a83
Improve panics
2020-04-24 22:34:23 +03:00
CreepySkeleton
1bbcfe2261
Do not print hash in debug builds
2020-04-24 19:19:36 +03:00
CreepySkeleton
739e7048a5
Make vec_map required dependency - in fact, it already is
2020-04-24 15:33:11 +03:00
CreepySkeleton
61a12e4296
Fix positional args in groups ( #1794 )
2020-04-24 13:05:46 +03:00
CreepySkeleton
2e959d6c71
Update tests
2020-04-24 11:15:55 +03:00
dylni
d12827076f
Give ArgStr
module a better name
2020-04-23 09:03:21 -04:00
dylni
e7b19aea58
Fix beta errors
2020-04-23 09:03:21 -04:00
dylni
9ef18519b1
Fix index calculation
2020-04-23 09:03:21 -04:00
dylni
c2246cf03f
imp(src/util/osstringext.rs): Remove the last unsafe block
2020-04-23 09:02:10 -04:00
bors[bot]
0293fd7c4a
Merge #1851
...
1851: Allow debug logs to work with clap tests themselves r=CreepySkeleton a=pksunkara
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-04-22 20:01:24 +00:00
Pavan Kumar Sunkara
f0074752b9
Improve debug logs
2020-04-22 20:56:35 +02:00
bors[bot]
c1cb0ce359
Merge #1849
...
1849: Arg enum r=CreepySkeleton a=pksunkara
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-04-22 17:23:43 +00:00
Pavan Kumar Sunkara
dbe6ac01f6
Clean up arg_enum
2020-04-22 14:38:16 +02:00
Pavan Kumar Sunkara
01c179f527
Added arg_enum support
2020-04-22 14:37:45 +02:00
bors[bot]
3de8af46a2
Merge #1850
...
1850: Bugfixes r=pksunkara a=CreepySkeleton
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-04-22 08:59:39 +00:00
CreepySkeleton
0e7ff777da
Make sure that command line OVERRIDES env, not prepends ( fix #1835 )
2020-04-22 11:35:20 +03:00
CreepySkeleton
dd1505fdfd
The self convention is not wrong here
2020-04-22 11:05:31 +03:00
Pavan Kumar Sunkara
4911c35869
Merge pull request #1834 from davidMcneil/arg_value_precedence_over_subcommand
...
Add ArgPrecedenceOverSubcommand app setting
2020-04-21 19:05:30 +02:00
David McNeil
746d9a4707
Fix SubcommandPrecedenceOverArg example indention
...
Signed-off-by: David McNeil <mcneil.david2@gmail.com>
2020-04-21 09:02:09 -05:00
David McNeil
709f20d713
Improve SubcommandPrecedenceOverArg description
...
Signed-off-by: David McNeil <mcneil.david2@gmail.com>
2020-04-21 08:31:49 -05:00
CreepySkeleton
66f85d07a0
Some extra debugging
2020-04-21 14:17:18 +03:00
David McNeil
ada5df3229
Use AppSettings::SubcommandPrecedenceOverArg
...
Signed-off-by: David McNeil <mcneil.david2@gmail.com>
2020-04-20 15:57:06 -05:00
bors[bot]
0a3921f554
Merge #1844
...
1844: Fix a couple of very minor bugs r=pksunkara a=CreepySkeleton
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-04-20 16:27:34 +00:00
CreepySkeleton
3b3d2b23fd
cargo clippy
2020-04-20 18:32:35 +03:00
bors[bot]
286c3e5d25
Merge #1841 #1842
...
1841: One less giant macro (-0.5 kB) r=pksunkara a=CreepySkeleton
1842: Allow rustc inline small functions across crates (-5.5 kB) r=pksunkara a=CreepySkeleton
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-04-20 15:27:55 +00:00
CreepySkeleton
4ce2a02f78
Corectly handle --foo==a (value is =a
)
2020-04-20 17:54:56 +03:00
CreepySkeleton
4d3760a0b3
Correctly handle -磨FOO
2020-04-20 15:15:28 +03:00
CreepySkeleton
32ffdfe855
Correctly handle -f==a
(value is =a
)
2020-04-20 13:41:37 +03:00
CreepySkeleton
f149f35da4
Allow rustc inline small functions across crates
2020-04-19 19:02:55 +03:00
CreepySkeleton
fae89db4a0
One less giant macro (-0.5 kB)
2020-04-19 15:42:08 +03:00
Donnie Adams
0584b57f29
fix: Don't print 'OPTIONS' when all options are hidden for short help
2020-04-16 08:21:41 -07:00
David McNeil
247231d1c6
Add ArgPrecedenceOverSubcommand app setting
...
Signed-off-by: David McNeil <mcneil.david2@gmail.com>
2020-04-16 09:08:39 -05:00
Pavan Kumar Sunkara
070bd50b28
Finished color refactor
2020-04-16 12:51:26 +02:00
bors[bot]
90e5eb6d1a
Merge #1831
...
1831: Handle publicity properly r=pksunkara a=CreepySkeleton
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-04-16 06:36:39 +00:00
CreepySkeleton
823332e919
Handle publicity properly
2020-04-16 08:29:16 +03:00
CreepySkeleton
8d01bce5df
Use ref instead of move
2020-04-16 04:52:02 +03:00
CreepySkeleton
f931c3d1e4
Suppress unused_valiables
lint in non-debug builds
2020-04-16 04:32:17 +03:00
CreepySkeleton
00f2a82c3e
Make debug output much more useful
2020-04-14 07:21:27 +03:00
CreepySkeleton
fdaf927384
Remove almost all #[doc(hidden)]
2020-04-14 04:26:12 +03:00
bors[bot]
500f34a8f6
Merge #1811
...
1811: Replace value_t*! macros with methods r=pksunkara a=CreepySkeleton
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-04-13 07:49:00 +00:00
CreepySkeleton
ecd60b69a3
Fix tests
2020-04-13 04:44:13 +03:00
CreepySkeleton
af95c2b6a4
Replace value_t*! macros with methods
2020-04-13 04:20:09 +03:00
Pavan Kumar Sunkara
da32adeb0e
Allow literals in builder macros
2020-04-12 23:18:39 +02:00
Pavan Kumar Sunkara
3bb8389c73
Enable ansi support for windows before refactoring
2020-04-12 10:20:08 +02:00
Pavan Kumar Sunkara
333b993481
Remove {n} support
2020-04-12 03:37:21 +02:00
CreepySkeleton
7cff206194
Make all fields of App & Arg pub(crate)
2020-04-11 18:23:20 +03:00
Bence Kalmar
4bf3f97d28
fix(arg_enum!): Invalid expansions of some trailing-comma patterns
...
In particular, fix macros that take an enum of one of the the following forms:
- `#[...] enum { ... , }`
- `pub enum { ... , }`
- `enum { ... , }`
Previously, these expansions would result in an error message like "error: no
rules expected the token `:`".
Add extensive tests for each pattern. Only two of the patterns had tests
before, so these errors did not surface automatically.
2020-04-10 09:35:20 +02:00
Ivan Veselov
0f3bdc439e
Fix ArgMatcher consuming extra arguments when max_values
is set
2020-04-10 09:35:20 +02:00
Pavan Kumar Sunkara
15edb69a0d
Address review comments
2020-04-10 00:33:16 +02:00
Pavan Kumar Sunkara
f0a216036b
Fix some issues
2020-04-09 19:41:33 +02:00
Pavan Kumar Sunkara
92449a4777
Assert arg groups
2020-04-09 16:51:32 +02:00
Pavan Kumar Sunkara
00a0b9660a
Assert for require* on args
2020-04-09 16:51:32 +02:00
Pavan Kumar Sunkara
f632aedc72
Started on arg asserts
2020-04-09 16:51:32 +02:00
Pavan Kumar Sunkara
1c16f73c10
Start cleaning up debug_assertion validations
2020-04-09 16:51:32 +02:00
Stephan Boyer
606d120d18
Update the documentation regarding which features are enabled by default
2020-04-04 13:16:30 -07:00
AimainaHito
06b9b32d66
Added full-stop
2020-04-04 11:30:30 +02:00
AimainaHito
f472393b14
Updated value_t documentation
2020-04-03 20:32:36 +02:00
Patrick Marks
4321cba5ba
set the default disp_ord of App to 999. Required for display_order and DeriveDisplay to work properly
2020-04-01 12:49:40 -07:00
Mátyás Mustoha
8687794986
style: fix comma placement for valid values when using arg_enum
2020-04-01 00:01:51 +02:00
Matthias Krüger
428a075e41
remove redundant imports and clone (found by clippy)
2020-03-25 13:43:01 +01:00
bors[bot]
2aa38e81a9
Merge #1739
...
1739: Remove _some_ of pubs r=pksunkara a=CreepySkeleton
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-03-19 23:53:18 +00:00
CreepySkeleton
a46ab1639a
Turn some integration tests into unit tests
2020-03-19 10:49:49 +03:00
CreepySkeleton
4fc4a00b8f
Remove _some_ of pubs
2020-03-19 10:17:52 +03:00
CreepySkeleton
b61a807728
Fix clippy and bump MSRV
2020-03-13 22:41:40 +03:00
CreepySkeleton
3e1f6ed514
Use proper cfg
2020-03-09 23:42:14 +03:00
CreepySkeleton
329bfa9895
Get rid of extra scopes
2020-03-09 21:08:15 +03:00
Julian Laubstein
c34a0fdae9
Added tests and fixed display of conflicted flags
2020-03-08 17:11:12 +01:00
Julian Laubstein
444bce2471
Fixed #1622
2020-03-08 16:39:14 +01:00
bors[bot]
19c20f7c00
Merge #1727
...
1727: Fix `-- subcommand` error r=pksunkara a=ldm0
Co-authored-by: Donough Liu <ldm2993593805@163.com>
2020-03-05 13:01:05 +00:00
Donough Liu
5b9f6197b1
Test added, Apply rustfmt
2020-03-05 20:02:48 +08:00
Donough Liu
79cec6a298
Fix misplaced subcommand matching failure emitter.
...
Only positional args follow `--`.
2020-03-05 18:38:55 +08:00
Donough Liu
bd1b73d7c8
Another Typo
2020-03-05 17:56:24 +08:00
Donough Liu
c86ac603f1
Typo
2020-03-05 17:17:07 +08:00
Pavan Kumar Sunkara
eaae1202cb
Basic github action for benchmarking
2020-03-05 09:21:39 +01:00
bors[bot]
5e0898c175
Merge #1718
...
1718: Fix core dump with mutually `requires()` args r=pksunkara a=CreepySkeleton
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-03-04 12:51:19 +00:00
CreepySkeleton
839ed2588c
Fix core dump with mutually requires()
args
...
Fixes #1643
2020-03-04 15:21:06 +03:00
Pavan Kumar Sunkara
47782cfac6
Make cargo feature additive
2020-03-01 22:55:57 +01:00
Ivan Tham
908b7aeb44
Ambiguous suggetions for InferSubcommands
...
Closes #1655
2020-03-01 19:36:05 +08:00
Emily
d36277b644
Fix Clap::try_parse_from documentation
2020-02-25 16:50:47 +00:00
bors[bot]
e4a7f50128
Merge #1669
...
1669: refactor: Rename Arg::conflicts_with_everything to Arg::exclusive (#1… r=pksunkara a=CreepySkeleton
Co-authored-by: Gregor Pfeifer <gpfeifer@dxc.com>
2020-02-22 21:58:29 +00:00
bors[bot]
28c46b5965
Merge #1697
...
1697: Allow replacing input on the fly r=CreepySkeleton a=pksunkara
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-02-21 19:13:59 +00:00
Pavan Kumar Sunkara
b8851a7d5e
Allow replacing input on the fly
2020-02-21 18:15:33 +01:00
Cecile Tonglet
35b918bd72
Allow missing docs on arg_enum
2020-02-21 11:39:44 +01:00
bors[bot]
cc79c432a4
Merge #1701
...
1701: Remove unneeded file r=pksunkara a=CreepySkeleton
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-02-21 09:51:56 +00:00
CreepySkeleton
4fcff089ef
Remove unneeded file
2020-02-21 03:28:25 +03:00
CreepySkeleton
4f13f3155c
Fix warnings on nightly
2020-02-21 01:55:19 +03:00
CreepySkeleton
43acfa00f4
Implement derive traits for Box<T>
2020-02-13 18:21:01 +03:00
bors[bot]
1e7c9efc9d
Merge #1612
...
1612: Use about() with help() and long_about() with long_help() r=pksunkara a=TheLostLambda
I was going through the clap documentation and was under the impression that calling `help()` would call `about()` and `long_help()` would call `long_about()`, but I've actually discovered this not to be the case. Instead, the `long_about()` was always shown when it existed, rendering the output (in the about section) of programs called with `-h` and `--help` identical. Issue #1472 shows this and that is fixed here.
Note this doesn't remove the ability to use the same about in both cases: if `long_about()` is unset, then `about()` is used in both cases.
I've changed the implementation here to use `is_some()` and `unwrap()` as opposed to `if let` because it ultimately allows for less repetitive code. Ideally, I'd be able to pair `if let` with a secondary condition (namely `self.use_long`), but to my dismay, let-chains are not stabilized yet.
For a second opinion, here is the code a settled on:
```
if self.use_long && parser.meta.long_about.is_some() {
debugln!("Help::write_default_help: writing long about");
write_thing!(parser.meta.long_about.unwrap())
} else if parser.meta.about.is_some() {
debugln!("Help::write_default_help: writing about");
write_thing!(parser.meta.about.unwrap())
}
```
Here is the alternative:
```
if self.use_long {
if let Some(about) = parser.meta.long_about {
debugln!("Help::write_default_help: writing long about");
write_thing!(about)
} else if let Some(about) = parser.meta.about {
debugln!("Help::write_default_help: writing about");
write_thing!(about)
}
} else {
if let Some(about) = parser.meta.about {
debugln!("Help::write_default_help: writing about");
write_thing!(about)
}
}
```
Co-authored-by: Brooks J Rady <b.j.rady@gmail.com>
2020-02-13 07:21:05 +00:00
Brooks J Rady
9cde072b61
Use about() with help() and long_about() with long_help()
2020-02-13 00:31:45 +00:00
bors[bot]
12df8cb078
Merge #1681
...
1681: WIP: Extract subcommands into separate trait r=pksunkara a=CreepySkeleton
Not-yet-working-but-almost-there "multiple traits" approach. More or less done, what's left is to catch some bugs and adapt tests/examples.
For the record: it took so long because of RL stuff (who would have thought?) and because [there was a detailed description of the experience I've had here, but it was deleted because it contained a lot of profanity and emotional notes].
As the only person alive that understands how the derive works (if you won't blow your own horn, nobody will do it for you, yeah), I'd like to made a statement: we Do need the refactoring.
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-02-12 20:42:32 +00:00
CreepySkeleton
ae574df2f9
Extract subcommands into separate trait
2020-02-12 23:15:05 +03:00
bors[bot]
0660e81231
Merge #1683
...
1683: Added HelpRequired AppSetting r=pksunkara a=thomasfermi
Closes #1683
There are likely some problems with my solution to this issue. I would be thankful for a review!
Co-authored-by: thomasfermi <mario.theers@gmail.com>
2020-02-10 17:47:40 +00:00
thomasfermi
f7b63c7be6
Implemented minor review findings.
2020-02-10 17:57:32 +01:00
thomasfermi
aa97a4e8aa
Added test for HelpRequired setting, which checks subcommands. Fixed bug that was discovered.
2020-02-10 14:33:26 +01:00
thomasfermi
2059bf1035
Implemented review findings for pull request #1683
2020-02-10 11:04:18 +01:00
thomasfermi
91f37f9358
Deleted unnecessary code in doc comments.
2020-02-09 21:37:19 +01:00
thomasfermi
48eb6a4530
Added HelpRequired AppSetting
2020-02-09 21:05:01 +01:00
bors[bot]
ad5606b5a0
Merge #1678
...
1678: Refactor clap_generate r=CreepySkeleton a=pksunkara
I have copied the code from [clap_generate]( https://github.com/clap-rs/clap_generate ) and refactored the structure a bit.
This new structure will allow people to write their own generators using our `Generator` trait which will contain some helpers (Still working on polishing them).
Co-authored-by: Ole Martin Ruud <barskern@outlook.com>
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-02-08 15:00:50 +00:00
Pavan Kumar Sunkara
33f47acc67
Refactor clap_generate
2020-02-07 07:52:04 +01:00
Pavan Kumar Sunkara
5b3a0dff9c
Remove extern & macro_use where possible
2020-02-07 07:34:01 +01:00
thomasfermi
582e2d39f3
Fixed typo
2020-02-05 17:24:40 +01:00
bors[bot]
509ac33a20
Merge #1664
...
1664: Import structopt r=pksunkara a=CreepySkeleton
OK, here is about 50% of what's left to import.
`impl StructOpt for Box<impl StructOpt>` is not imported because layouts of `StructOpt` and `Clap` are too different. I'll work it out after the import is done.
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg " height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/clap-rs/clap/1664 )
<!-- Reviewable:end -->
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
Co-authored-by: Cecile Tonglet <cecile.tonglet@cecton.com>
Co-authored-by: David McNeil <mcneil.david2@gmail.com>
2020-02-05 08:43:57 +00:00
bors[bot]
e7d3600128
Merge #1670
...
1670: Minor refactoring r=pksunkara a=CreepySkeleton
Some minor improvements. Also gets some bugs fixed
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg " height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/clap-rs/clap/1670 )
<!-- Reviewable:end -->
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-02-05 08:23:28 +00:00
CreepySkeleton
ffad57c776
Update src/macros.rs
...
Co-Authored-By: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-02-05 10:44:20 +03:00
CreepySkeleton
28605ba326
Fix macro
2020-02-05 10:17:11 +03:00
CreepySkeleton
afac737f69
Minor refactoring
2020-02-04 19:02:29 +03:00
Gregor Pfeifer
7781fd8813
refactor: Rename Arg::conflicts_with_everything to Arg::exclusive ( #1583 ) ( #1624 )
...
https://github.com/clap-rs/clap/pull/1624#issuecomment-571372359
2020-02-04 18:02:47 +03:00
rleungx
4082d1e85c
exactly match a subcommand when using the infersubcommands
2020-02-04 09:41:05 +01:00
CreepySkeleton
cf11d46373
Default value for default_value
(yeah, sounds awkward)
2020-02-04 11:40:01 +03:00
Alex van de Sandt
050bb7484a
Fix formatting
2020-02-03 13:04:07 -05:00
Alex van de Sandt
47031213a2
Remove needless fn main
from doc tests
2020-02-03 12:31:24 -05:00
Alex van de Sandt
928ded9d42
Revert "Remove #[macro_use]
from src"
...
This reverts commit 7dcdfc8b231b41a46d4d7ab7ec2664d32804b4a3.
That commit caused doc tests to break, as well as issues with importing
macros in other modules. Note that the yaml example in `src/lib.rs` at
line 184 is broken and should probably be fixed.
2020-02-03 12:04:13 -05:00
Alex van de Sandt
fd6b32ff55
Remove #[macro_use]
from src
2020-02-03 12:04:13 -05:00
Pavan Kumar Sunkara
c5eb08431a
Apply suggestions from code review
2020-02-03 12:37:37 +01:00
Dylan DPC
a2ff3fa91b
Revert " imp: Add exitcode::USAGE exit code as suggested in #1327 "
2020-02-03 12:37:37 +01:00
Toothless204
ebdc0453eb
Update src/build/arg/mod.rs
...
make error message more descriptive
Co-Authored-By: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-02-02 12:19:55 +00:00
Toothless204
8b2a9928e8
added check for -
2020-02-02 11:48:35 +00:00
Dylan DPC
922a531fa6
Update lib.rs
2020-02-02 02:02:10 +01:00
Pavan Kumar Sunkara
2a6005657e
Apply suggestions from code review
...
Co-Authored-By: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-02-01 06:55:47 +01:00
Pavan Kumar Sunkara
dd75cee72c
fix: Clippy should pass
2020-02-01 06:48:50 +01:00
Daniel Eades
d23df44e84
refactor: remove deprecated 'Error::description' method
2020-01-31 18:37:56 +01:00
Pavan Kumar Sunkara
8e4a189ab0
fmt: Use standardized rustfmt rules
2020-01-31 18:37:56 +01:00
Pavan Kumar Sunkara
c799e8d0ca
chore: Updated contributing instructions and justfile
2020-01-31 18:37:56 +01:00
Daniel Gray
a1445b0f3b
imp: Add exitcode::USAGE exit code as suggested in #1327
...
The reason to do this is described well in issue #1327 . It is also a
recommendation of the Rust book itself:
https://rust-cli.github.io/book/in-depth/exit-code.html
2020-01-17 11:20:45 -04:00
Luca Bruno
f3683a9792
output: get rid of an unsafe block ( #1636 )
...
* parse: fix build in debug mode
This fixes a build failure in debug mode, as the value to be printed
does not implement Display.
* output: get rid of an unsafe block
This get rid of an unsafe block which is not necessary, and only used
when building in debug mode.
2020-01-17 19:05:18 +05:30
danieleades
af45420027
style: format code with rustfmt ( #1632 )
...
> incidentally, how do we feel about adding a rustfmt check to the CI(s)?
yes we should be doing that. you can send another pr that adds the check to the Ci
2020-01-11 23:45:46 +05:30
Jeremy Stucki
2e1acb648c
Refactor mkeymap ( #1618 )
...
* refactor(mkeymap): Use iterators
* refactor(mkeymap): Implement contains method
* refactor(mkeymap): Deprecate methods
Co-authored-by: Dylan DPC <dylan.dpc@gmail.com>
2020-01-09 23:00:22 +05:30
Gregor Pfeifer
8b5ecf92e4
fix: Typos in Arg::conflicts_with_everything` ( #1625 )
...
Related to https://github.com/clap-rs/clap/pull/1624
2020-01-06 00:50:15 +05:30
Gregor Pfeifer
6180d42c00
feat: Add Arg::conflicts_with_everything
method #1583 ( #1624 )
...
* feat: Add `Arg::conflicts_with_everything` method #1583
* fix: Typo in src/build/arg/mod.rs
Co-Authored-By: Dylan DPC <dylan.dpc@gmail.com>
Co-authored-by: Dylan DPC <dylan.dpc@gmail.com>
2020-01-06 00:16:28 +05:30
xidaxmb
f402f7a113
imp(usage_parser.rs): add default value support ( #1522 )
...
Co-authored-by: Dylan DPC <dylan.dpc@gmail.com>
2020-01-03 17:18:09 +05:30
dylan_DPC
1c79bb5b28
fix subcommand is private bug
2020-01-01 23:28:06 +05:30
ncaq
fc359e3c46
fixed: failed of multiple_occurrences with env ( #1609 )
...
The example code.
~~~rust
use clap::{App, Arg};
fn main() {
let matches = App::new("My Super Program")
.arg(
Arg::with_name("verbose")
.help("Sets the level of verbosity")
.short('v')
.long("verbose")
.takes_value(false)
.multiple_occurrences(true)
.env("VERBOSE"),
)
.get_matches();
match matches.occurrences_of("verbose") {
0 => println!("0 No verbose info"),
1 => println!("1 Some verbose info"),
2 => println!("2 Tons of verbose info"),
3 | _ => println!("3 >= Don't be crazy"),
}
}
~~~
It code use multiple_occurrences with env.
But it do not work.
`env` method set require take value.
It result see under.
~~~console
% cargo run -- -v
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running `target/debug/foo -v`
error: The argument '--verbose <verbose>...' requires a value but none was supplied
USAGE:
foo [OPTIONS]
For more information try --help
~~~
And, structopt or clap_derive may be create similar code.
So I am confused by structopt.
This to fix code small.
2019-12-22 23:03:23 +05:30
Mara Bos
2a2969aee4
Don't write --version output directly to stdout. ( #1602 )
...
Fixes #1390 .
2019-11-26 18:39:12 +01:00
Dylan DPC
335f34bee2
fix broken CI
2019-11-11 14:28:30 +01:00
Dylan DPC
dd6c8e08ad
use 2018 edition and minor refactors
2019-11-11 12:54:55 +01:00
Kevin K
750796b9ca
Merge branch 'master' into one-less-unsafe
2019-11-03 14:21:56 -05:00
Stéphane Campinas
4d69942db7
fix(Error): remove Copy trait bound by formatting both plain and colored error cause at the same time
2019-11-02 21:36:16 +01:00
Stéphane Campinas
991b839069
refactor(Error): add cause field to group_conflict error
2019-11-02 21:36:16 +01:00
Stéphane Campinas
15ad5954b0
feat(Error): add a cause field to the Error struct
...
The cause field is the actual error described in the message field,
however without extra information like usage.
Close #861
2019-11-02 21:36:11 +01:00
Sergey "Shnatsel" Davidoff
0a010a4371
Add comment on performance
2019-11-02 21:03:35 +01:00