Commit graph

324 commits

Author SHA1 Message Date
CreepySkeleton
e9759a241b Adjust examples and tests 2020-08-05 17:07:13 +03:00
Nicholas Nethercote
7fb397d905 refactor: Simplify some it.any(...) calls. 2020-07-29 10:35:34 +10: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
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
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
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
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
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
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
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
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
Pavan Kumar Sunkara
1a276f8f4f Remove Arg::help 2020-06-10 09:34:55 +02: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
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
Pavan Kumar Sunkara
aab2e41f8a Consistent From<Yaml> for ArgGroup 2020-05-15 13:59:31 +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
Charles Hall
1019724026 setting(DisableHelpFlags): disable the automatic generation of the -h/--help flags 2020-05-12 00:55:49 +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
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
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
ec6b6e1e36 Make validator take &str instead of String 2020-05-01 14:21:11 +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
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
f69ec92a83 Improve panics 2020-04-24 22:34:23 +03:00
CreepySkeleton
61a12e4296 Fix positional args in groups (#1794) 2020-04-24 13:05:46 +03: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
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
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
CreepySkeleton
f149f35da4 Allow rustc inline small functions across crates 2020-04-19 19:02:55 +03: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
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
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
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
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
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
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
CreepySkeleton
839ed2588c Fix core dump with mutually requires() args
Fixes #1643
2020-03-04 15:21:06 +03: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
CreepySkeleton
4f13f3155c Fix warnings on nightly 2020-02-21 01:55:19 +03: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]
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
28605ba326 Fix macro 2020-02-05 10:17:11 +03:00