summaryrefslogtreecommitdiffstats
path: root/vendor/clap_builder
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:24 +0000
commit023939b627b7dc93b01471f7d41fb8553ddb4ffa (patch)
tree60fc59477c605c72b0a1051409062ddecc43f877 /vendor/clap_builder
parentAdding debian version 1.72.1+dfsg1-1. (diff)
downloadrustc-023939b627b7dc93b01471f7d41fb8553ddb4ffa.tar.xz
rustc-023939b627b7dc93b01471f7d41fb8553ddb4ffa.zip
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/clap_builder')
-rw-r--r--vendor/clap_builder/.cargo-checksum.json2
-rw-r--r--vendor/clap_builder/Cargo.toml2
-rw-r--r--vendor/clap_builder/src/builder/action.rs62
-rw-r--r--vendor/clap_builder/src/builder/arg.rs10
-rw-r--r--vendor/clap_builder/src/builder/command.rs16
-rw-r--r--vendor/clap_builder/src/builder/debug_asserts.rs51
-rw-r--r--vendor/clap_builder/src/builder/mod.rs9
-rw-r--r--vendor/clap_builder/src/builder/styled_str.rs161
-rw-r--r--vendor/clap_builder/src/builder/styling.rs181
-rw-r--r--vendor/clap_builder/src/builder/value_parser.rs59
-rw-r--r--vendor/clap_builder/src/error/mod.rs25
-rw-r--r--vendor/clap_builder/src/output/help_template.rs84
-rw-r--r--vendor/clap_builder/src/output/usage.rs15
-rw-r--r--vendor/clap_builder/src/parser/parser.rs27
14 files changed, 439 insertions, 265 deletions
diff --git a/vendor/clap_builder/.cargo-checksum.json b/vendor/clap_builder/.cargo-checksum.json
index 715fae273..6767a5bd9 100644
--- a/vendor/clap_builder/.cargo-checksum.json
+++ b/vendor/clap_builder/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"dad9147ab3cb6debd20bf49fab7f302221613b0de8605365aa4d92a16730f9b6","LICENSE-APACHE":"c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4","LICENSE-MIT":"0d687e1f07b58fe68bda74668ff6326125e5e5efa184cce755cd84ac535b7058","README.md":"60b99346464866941b21928d3c4699fd6a3ca85a541da7577f60bc691b7afef8","src/builder/action.rs":"c68eff7584e63c94f0ba496613b46658c6001156b791bd9cda56a8d153f1a315","src/builder/app_settings.rs":"286f925717fa54fe9d2ed6f2f338293b7a5981fee0fe687fe706118cebf1f6f4","src/builder/arg.rs":"3084e103153c1b511ff3fe9e11b98ae8dfbf4a749707892538ddf244e7379ccf","src/builder/arg_group.rs":"82a6e9afeea1792a4ca99baa3b0d3235eb012b037cc19333ed9b03a13bb66f30","src/builder/arg_predicate.rs":"4fe55fdd0441acb1577f28188c86f920df4863f451a7dcad8e050dbb6e1e7516","src/builder/arg_settings.rs":"e8ad1bd6d36da43d7329b6cd86833d4cc63734e64119c6b950a45ded5e3aec9c","src/builder/command.rs":"44e27c4902eda449c80aeff986eb25ebf70828662e420b33940c43e1dbc0af9c","src/builder/debug_asserts.rs":"d98f70a6d6f568a6cd47c0ea5cdad0bce132370c5cd59d8602c692448e4a9fc9","src/builder/ext.rs":"736cfb56f765cbe23301ebcad83fbe3edfc778954edc4747ccf7c23104d85638","src/builder/mod.rs":"5be61d8febaf052f8997edfa88c97d02f271234e2efa672cf686786cf4b93720","src/builder/os_str.rs":"2b635e4fa8ecc42ad1d964a8b2f0fe17aa57d976c163d3bf77f213de254d844f","src/builder/possible_value.rs":"2ed44c5a353c0abab337ac0f00995066f96ff27c33098613642725991163edff","src/builder/range.rs":"bdaa3da849b74dc42a6b6ace87870329d34632e93fa9905a45b2fe86f549220a","src/builder/resettable.rs":"c4cd481051ec361529817ebae73b4dd307b0a4a3b88a3ddcecb8dd45b05db431","src/builder/str.rs":"e51a1e5c18364c9132d1c7df113e6a462265e40f767087fa9664bfcd5f5d91b4","src/builder/styled_str.rs":"52e7811859e826c5249c6bd873fc45876f9ff7ac533a561dfe0143eb5aac58eb","src/builder/tests.rs":"565f5efd38c6596e55fa1c077a11cc07be94ca201527963d27fd42ddce6dbbe8","src/builder/value_hint.rs":"66588792cddf7e3bb2912da4e0a53584169c266f9e4e6dcb990295998d158f93","src/builder/value_parser.rs":"03fc008a18f69ef1924720b3c270c03074b24c0e1952632283aa370bff955da8","src/derive.rs":"201404c128c92ce59d6c88931ba789e389508334852b758ae620aa3e2ccf930c","src/error/context.rs":"156d2611a349ce826378476c9dcb3242a01ad834a095baad096a10cc2f73e1ed","src/error/format.rs":"33903b182f9b8fde0a2ad2f5f96582ed3812d37c51a03f2c775553db8351e5e8","src/error/kind.rs":"29603c64b8cea7886498afc3f7e7c489505c9820c5159e99d153d57fdafe95ec","src/error/mod.rs":"42f1f0e1f6fd8de76bd2f6cb825a5ca083a95e53e0ecc47a6e87b9b7b150b828","src/lib.rs":"9295447fadf8a95dfcffa93bf5824c5235d8b3449cd5d1463d88b291f40972f6","src/macros.rs":"fc190536cd2b39cfe6b55a351df3f8402e81c6a6966208d1fdb36c4b48dbc72f","src/mkeymap.rs":"473eb25f9bf0017ade3a93e4cf6d27da4e3f5b4b64767a090cadbb56b9483957","src/output/fmt.rs":"17d7c95bae851fd0ffb7d3ea4c3c1830963c8b863aa8e4e296e3d824a1da18dc","src/output/help.rs":"1eea985c582395431ae5a8de6c1fcc4ca76317f61144ef46c6d530fda330ea7a","src/output/help_template.rs":"a386c31d136a17c7f26130027b2969084d88cd9eb50bcc5680586c13649d99b6","src/output/mod.rs":"74ea52be8981c30d10fda3f6c80cf51aafb15700de99aa73bc94700bca25ae11","src/output/textwrap/core.rs":"0d45b1ebe8bba3e54e8bcbfec015be626d55803a0a46aef753eb3a4be3cabab4","src/output/textwrap/mod.rs":"1bc5056701b6651a98b0eea482db5235ba3342a24a02d776ad364fec6919cecc","src/output/textwrap/word_separators.rs":"ae3af310295e707ae1aa95633f6bb078cedf8f65662a86caa9d25420f459acc1","src/output/textwrap/wrap_algorithms.rs":"a6eb1491ef5e64dbd2ef55d367e46747fcf2fb22fdb66a2b7c3cb9ba3a02d86a","src/output/usage.rs":"620e2fa7f6b30954a6ed8a9b90d1b99cdcf1e85c446c1c176430e7cbb02648d0","src/parser/arg_matcher.rs":"b6f17cfc48d18d192d6f4f45b9daf342b93d847ce7d52a3f68266c15566c3849","src/parser/error.rs":"7def6f001ad6dfd262d71149c6e4f3845a6f7bf246a92edc6d872e3ca4e2ae01","src/parser/features/mod.rs":"6ed075e97af56bff22f22ed1ee83ff6479360e05f9d3661a3145f822c242b694","src/parser/features/suggestions.rs":"832b62f927f9f4ffb95abdcef09c8b675045aab0b5471bae484e5d07f18f7621","src/parser/matches/arg_matches.rs":"8386f3d69141678074751ee26c8d7888fe320d07cc1fb6034341adb99f4eee13","src/parser/matches/matched_arg.rs":"8533197ac8f1a1a218844c34923beabd0ed0d28447b03bd9d4d199cc7ff251d0","src/parser/matches/mod.rs":"5578335f4b9103cc4060546621e5664d5e92c43848ec48c2d95a4b045373de1f","src/parser/matches/value_source.rs":"ecb9e09db06579489daa9cbcf351381041dff7c5e2956fb96052b70b9360955b","src/parser/mod.rs":"34d689dac5d878790e5c29872f59ccec000ceab737ddaa642054cb464e26edb8","src/parser/parser.rs":"126feed5249afe8939a7a7b86587fd085d92287561567ea8e218c7e925b4d6c4","src/parser/validator.rs":"107c4eaa1615c0414553862f0250e9bf4241cccb7d7ec6df4ac8784f5f850d11","src/util/any_value.rs":"f3666cf322e87daf83f1474d5449e9b526b80b835f032e4090c5e1abddf6f044","src/util/color.rs":"04cc72927ad1e7f5490e1db39b7f79b16ed613b7b81cfe0285b38ba9d0afb875","src/util/flat_map.rs":"89e6471d099485f943ed7331626db6fddd75598f2c98623a13f262ff1a08b509","src/util/flat_set.rs":"334f3b8a72a897fbabd68f2330a8ecc18af74492036822b2e3764d461ddf31b4","src/util/graph.rs":"f35396b6e2a427377dcbbca69b1b98737d89684a3834cfda98cbf8cc70ff9c2f","src/util/id.rs":"5f025a05e4752ef7d610d6490f4a83ab489b1e5038c1a15067c0be51caafde87","src/util/mod.rs":"010f54d58906f4ae0106f2f1a891ea80a55fd52c64b8946a6b59e20f9c502418","src/util/str_to_bool.rs":"1ce90b4939a884eeefc73392722bdfcf906e3070c4398e1557c586c10c684cd0"},"package":"ef137bbe35aab78bdb468ccfba75a5f4d8321ae011d34063770780545176af2d"} \ No newline at end of file
+{"files":{"Cargo.toml":"09f09455758e977503cd682e65252b3c428fb60e5f9d6b8fe09060b5ad9d9d32","LICENSE-APACHE":"c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4","LICENSE-MIT":"0d687e1f07b58fe68bda74668ff6326125e5e5efa184cce755cd84ac535b7058","README.md":"60b99346464866941b21928d3c4699fd6a3ca85a541da7577f60bc691b7afef8","src/builder/action.rs":"9b920d2d405825ce89a5ba3b59edc66e3b849841819e9742b19010a81584fee7","src/builder/app_settings.rs":"286f925717fa54fe9d2ed6f2f338293b7a5981fee0fe687fe706118cebf1f6f4","src/builder/arg.rs":"cfe91d01f953dcc1b0e103e88f4425a34f64e8c1261f6fc38ef666a5577b99b5","src/builder/arg_group.rs":"82a6e9afeea1792a4ca99baa3b0d3235eb012b037cc19333ed9b03a13bb66f30","src/builder/arg_predicate.rs":"4fe55fdd0441acb1577f28188c86f920df4863f451a7dcad8e050dbb6e1e7516","src/builder/arg_settings.rs":"e8ad1bd6d36da43d7329b6cd86833d4cc63734e64119c6b950a45ded5e3aec9c","src/builder/command.rs":"c366814ca5869e0a6784696d776cc4bbcf05b75ee5559f3f778bb6d085e18298","src/builder/debug_asserts.rs":"8422c3be1c6565c09683e0225ee54a9e2e5cdd21c91376822e46abdb68deb10a","src/builder/ext.rs":"736cfb56f765cbe23301ebcad83fbe3edfc778954edc4747ccf7c23104d85638","src/builder/mod.rs":"c9cd69cd3d1248a82d7790f97932bea0f2ff21acfc7980833939a0f97aa0073d","src/builder/os_str.rs":"2b635e4fa8ecc42ad1d964a8b2f0fe17aa57d976c163d3bf77f213de254d844f","src/builder/possible_value.rs":"2ed44c5a353c0abab337ac0f00995066f96ff27c33098613642725991163edff","src/builder/range.rs":"bdaa3da849b74dc42a6b6ace87870329d34632e93fa9905a45b2fe86f549220a","src/builder/resettable.rs":"c4cd481051ec361529817ebae73b4dd307b0a4a3b88a3ddcecb8dd45b05db431","src/builder/str.rs":"e51a1e5c18364c9132d1c7df113e6a462265e40f767087fa9664bfcd5f5d91b4","src/builder/styled_str.rs":"df58c3a2bdfdcb0a11da5eb1ef6ed411d68c455a4df9a37a458663c21b0cbeb9","src/builder/styling.rs":"4ea1552731976a824d61b7880f21859a6030b2a1037e76dda8e74d009eb571f6","src/builder/tests.rs":"565f5efd38c6596e55fa1c077a11cc07be94ca201527963d27fd42ddce6dbbe8","src/builder/value_hint.rs":"66588792cddf7e3bb2912da4e0a53584169c266f9e4e6dcb990295998d158f93","src/builder/value_parser.rs":"03020c9b2da9c7129196338a3de1336932eeb54ddc08bfcef9cd198eb56603e3","src/derive.rs":"201404c128c92ce59d6c88931ba789e389508334852b758ae620aa3e2ccf930c","src/error/context.rs":"156d2611a349ce826378476c9dcb3242a01ad834a095baad096a10cc2f73e1ed","src/error/format.rs":"33903b182f9b8fde0a2ad2f5f96582ed3812d37c51a03f2c775553db8351e5e8","src/error/kind.rs":"29603c64b8cea7886498afc3f7e7c489505c9820c5159e99d153d57fdafe95ec","src/error/mod.rs":"f5a6f3ba9273421cff91bd0a0998549a5b886b5832129f02830fbb1cc95b176e","src/lib.rs":"9295447fadf8a95dfcffa93bf5824c5235d8b3449cd5d1463d88b291f40972f6","src/macros.rs":"fc190536cd2b39cfe6b55a351df3f8402e81c6a6966208d1fdb36c4b48dbc72f","src/mkeymap.rs":"473eb25f9bf0017ade3a93e4cf6d27da4e3f5b4b64767a090cadbb56b9483957","src/output/fmt.rs":"17d7c95bae851fd0ffb7d3ea4c3c1830963c8b863aa8e4e296e3d824a1da18dc","src/output/help.rs":"1eea985c582395431ae5a8de6c1fcc4ca76317f61144ef46c6d530fda330ea7a","src/output/help_template.rs":"19e725674a92ef2a529e7583c0c139d04a420617be5e91e65341a2063b3d8a68","src/output/mod.rs":"74ea52be8981c30d10fda3f6c80cf51aafb15700de99aa73bc94700bca25ae11","src/output/textwrap/core.rs":"0d45b1ebe8bba3e54e8bcbfec015be626d55803a0a46aef753eb3a4be3cabab4","src/output/textwrap/mod.rs":"1bc5056701b6651a98b0eea482db5235ba3342a24a02d776ad364fec6919cecc","src/output/textwrap/word_separators.rs":"ae3af310295e707ae1aa95633f6bb078cedf8f65662a86caa9d25420f459acc1","src/output/textwrap/wrap_algorithms.rs":"a6eb1491ef5e64dbd2ef55d367e46747fcf2fb22fdb66a2b7c3cb9ba3a02d86a","src/output/usage.rs":"45dcf5520f0625da75f1ceb1d749aaeb13db882f64025ea89d039a2acfd72898","src/parser/arg_matcher.rs":"b6f17cfc48d18d192d6f4f45b9daf342b93d847ce7d52a3f68266c15566c3849","src/parser/error.rs":"7def6f001ad6dfd262d71149c6e4f3845a6f7bf246a92edc6d872e3ca4e2ae01","src/parser/features/mod.rs":"6ed075e97af56bff22f22ed1ee83ff6479360e05f9d3661a3145f822c242b694","src/parser/features/suggestions.rs":"832b62f927f9f4ffb95abdcef09c8b675045aab0b5471bae484e5d07f18f7621","src/parser/matches/arg_matches.rs":"8386f3d69141678074751ee26c8d7888fe320d07cc1fb6034341adb99f4eee13","src/parser/matches/matched_arg.rs":"8533197ac8f1a1a218844c34923beabd0ed0d28447b03bd9d4d199cc7ff251d0","src/parser/matches/mod.rs":"5578335f4b9103cc4060546621e5664d5e92c43848ec48c2d95a4b045373de1f","src/parser/matches/value_source.rs":"ecb9e09db06579489daa9cbcf351381041dff7c5e2956fb96052b70b9360955b","src/parser/mod.rs":"34d689dac5d878790e5c29872f59ccec000ceab737ddaa642054cb464e26edb8","src/parser/parser.rs":"1e7e6adac83f3a4621880e0104589481dfbad56d62106fcc23a49edb3dcbfe9a","src/parser/validator.rs":"107c4eaa1615c0414553862f0250e9bf4241cccb7d7ec6df4ac8784f5f850d11","src/util/any_value.rs":"f3666cf322e87daf83f1474d5449e9b526b80b835f032e4090c5e1abddf6f044","src/util/color.rs":"04cc72927ad1e7f5490e1db39b7f79b16ed613b7b81cfe0285b38ba9d0afb875","src/util/flat_map.rs":"89e6471d099485f943ed7331626db6fddd75598f2c98623a13f262ff1a08b509","src/util/flat_set.rs":"334f3b8a72a897fbabd68f2330a8ecc18af74492036822b2e3764d461ddf31b4","src/util/graph.rs":"f35396b6e2a427377dcbbca69b1b98737d89684a3834cfda98cbf8cc70ff9c2f","src/util/id.rs":"5f025a05e4752ef7d610d6490f4a83ab489b1e5038c1a15067c0be51caafde87","src/util/mod.rs":"010f54d58906f4ae0106f2f1a891ea80a55fd52c64b8946a6b59e20f9c502418","src/util/str_to_bool.rs":"1ce90b4939a884eeefc73392722bdfcf906e3070c4398e1557c586c10c684cd0"},"package":"01c6a3f08f1fe5662a35cfe393aec09c4df95f60ee93b7556505260f75eee9e1"} \ No newline at end of file
diff --git a/vendor/clap_builder/Cargo.toml b/vendor/clap_builder/Cargo.toml
index 0f05ef88f..30457b0ce 100644
--- a/vendor/clap_builder/Cargo.toml
+++ b/vendor/clap_builder/Cargo.toml
@@ -13,7 +13,7 @@
edition = "2021"
rust-version = "1.64.0"
name = "clap_builder"
-version = "4.3.10"
+version = "4.3.19"
include = [
"build.rs",
"src/**/*",
diff --git a/vendor/clap_builder/src/builder/action.rs b/vendor/clap_builder/src/builder/action.rs
index 79ee9238e..2def801f4 100644
--- a/vendor/clap_builder/src/builder/action.rs
+++ b/vendor/clap_builder/src/builder/action.rs
@@ -257,6 +257,58 @@ pub enum ArgAction {
/// # }
/// ```
Help,
+ /// When encountered, display [`Command::print_help`][super::Command::print_help]
+ ///
+ /// # Examples
+ ///
+ /// ```rust
+ /// # #[cfg(feature = "help")] {
+ /// # use clap_builder as clap;
+ /// # use clap::Command;
+ /// # use clap::Arg;
+ /// let cmd = Command::new("mycmd")
+ /// .arg(
+ /// Arg::new("special-help")
+ /// .short('?')
+ /// .action(clap::ArgAction::HelpShort)
+ /// );
+ ///
+ /// // Existing help still exists
+ /// let err = cmd.clone().try_get_matches_from(["mycmd", "-h"]).unwrap_err();
+ /// assert_eq!(err.kind(), clap::error::ErrorKind::DisplayHelp);
+ ///
+ /// // New help available
+ /// let err = cmd.try_get_matches_from(["mycmd", "-?"]).unwrap_err();
+ /// assert_eq!(err.kind(), clap::error::ErrorKind::DisplayHelp);
+ /// # }
+ /// ```
+ HelpShort,
+ /// When encountered, display [`Command::print_long_help`][super::Command::print_long_help]
+ ///
+ /// # Examples
+ ///
+ /// ```rust
+ /// # #[cfg(feature = "help")] {
+ /// # use clap_builder as clap;
+ /// # use clap::Command;
+ /// # use clap::Arg;
+ /// let cmd = Command::new("mycmd")
+ /// .arg(
+ /// Arg::new("special-help")
+ /// .short('?')
+ /// .action(clap::ArgAction::HelpLong)
+ /// );
+ ///
+ /// // Existing help still exists
+ /// let err = cmd.clone().try_get_matches_from(["mycmd", "-h"]).unwrap_err();
+ /// assert_eq!(err.kind(), clap::error::ErrorKind::DisplayHelp);
+ ///
+ /// // New help available
+ /// let err = cmd.try_get_matches_from(["mycmd", "-?"]).unwrap_err();
+ /// assert_eq!(err.kind(), clap::error::ErrorKind::DisplayHelp);
+ /// # }
+ /// ```
+ HelpLong,
/// When encountered, display [`Command::version`][super::Command::version]
///
/// Depending on the flag, [`Command::long_version`][super::Command::long_version] may be shown
@@ -299,6 +351,8 @@ impl ArgAction {
Self::SetFalse => false,
Self::Count => false,
Self::Help => false,
+ Self::HelpShort => false,
+ Self::HelpLong => false,
Self::Version => false,
}
}
@@ -311,6 +365,8 @@ impl ArgAction {
Self::SetFalse => Some(std::ffi::OsStr::new("true")),
Self::Count => Some(std::ffi::OsStr::new("0")),
Self::Help => None,
+ Self::HelpShort => None,
+ Self::HelpLong => None,
Self::Version => None,
}
}
@@ -323,6 +379,8 @@ impl ArgAction {
Self::SetFalse => Some(std::ffi::OsStr::new("false")),
Self::Count => None,
Self::Help => None,
+ Self::HelpShort => None,
+ Self::HelpLong => None,
Self::Version => None,
}
}
@@ -335,6 +393,8 @@ impl ArgAction {
Self::SetFalse => Some(super::ValueParser::bool()),
Self::Count => Some(crate::value_parser!(u8).into()),
Self::Help => None,
+ Self::HelpShort => None,
+ Self::HelpLong => None,
Self::Version => None,
}
}
@@ -348,6 +408,8 @@ impl ArgAction {
Self::SetFalse => None,
Self::Count => Some(AnyValueId::of::<CountType>()),
Self::Help => None,
+ Self::HelpShort => None,
+ Self::HelpLong => None,
Self::Version => None,
}
}
diff --git a/vendor/clap_builder/src/builder/arg.rs b/vendor/clap_builder/src/builder/arg.rs
index 5bfea9ad4..d067dec1d 100644
--- a/vendor/clap_builder/src/builder/arg.rs
+++ b/vendor/clap_builder/src/builder/arg.rs
@@ -1650,6 +1650,8 @@ impl Arg {
/// at runtime, nor were the conditions met for `Arg::default_value_if`, the `Arg::default_value`
/// will be applied.
///
+ /// Like with command-line values, this will be split by [`Arg::value_delimiter`].
+ ///
/// # Examples
///
/// First we use the default value without providing any value at runtime.
@@ -1747,6 +1749,8 @@ impl Arg {
/// [`.require_equals(true)`][Arg::require_equals] configuration option. These are required in
/// order to unambiguously determine what, if any, value was supplied for the argument.
///
+ /// Like with command-line values, this will be split by [`Arg::value_delimiter`].
+ ///
/// # Examples
///
/// For POSIX style `--color`:
@@ -1893,6 +1897,8 @@ impl Arg {
/// [`ArgMatches::get_one`][crate::ArgMatches::get_one] will
/// return the default specified.
///
+ /// Like with command-line values, this will be split by [`Arg::value_delimiter`].
+ ///
/// # Examples
///
/// In this example, we show the variable coming from the environment:
@@ -2734,6 +2740,8 @@ impl Arg {
/// and `Arg::default_value_if`, and the user **did not** provide this arg at runtime, nor were
/// the conditions met for `Arg::default_value_if`, the `Arg::default_value` will be applied.
///
+ /// Like with command-line values, this will be split by [`Arg::value_delimiter`].
+ ///
/// # Examples
///
/// First we use the default value only if another arg is present at runtime.
@@ -2873,6 +2881,8 @@ impl Arg {
/// **NOTE**: The conditions are stored in order and evaluated in the same order. I.e. the first
/// if multiple conditions are true, the first one found will be applied and the ultimate value.
///
+ /// Like with command-line values, this will be split by [`Arg::value_delimiter`].
+ ///
/// # Examples
///
/// First we use the default value only if another arg is present at runtime.
diff --git a/vendor/clap_builder/src/builder/command.rs b/vendor/clap_builder/src/builder/command.rs
index 2c5eb1989..b2efdbc7e 100644
--- a/vendor/clap_builder/src/builder/command.rs
+++ b/vendor/clap_builder/src/builder/command.rs
@@ -1111,9 +1111,14 @@ impl Command {
///
/// ```no_run
/// # use clap_builder as clap;
- /// # use clap::{Command, ColorChoice, builder::Styles};
+ /// # use clap::{Command, ColorChoice, builder::styling};
+ /// let styles = styling::Styles::styled()
+ /// .header(styling::AnsiColor::Green.on_default() | styling::Effects::BOLD)
+ /// .usage(styling::AnsiColor::Green.on_default() | styling::Effects::BOLD)
+ /// .literal(styling::AnsiColor::Blue.on_default() | styling::Effects::BOLD)
+ /// .placeholder(styling::AnsiColor::Cyan.on_default());
/// Command::new("myprog")
- /// .styles(Styles::styled().usage(Default::default()))
+ /// .styles(styles)
/// .get_matches();
/// ```
#[cfg(feature = "color")]
@@ -1132,6 +1137,9 @@ impl Command {
/// Defaults to current terminal width when `wrap_help` feature flag is enabled. If current
/// width cannot be determined, the default is 100.
///
+ /// **`unstable-v5` feature**: Defaults to unbound, being subject to
+ /// [`Command::max_term_width`].
+ ///
/// **NOTE:** This setting applies globally and *not* on a per-command basis.
///
/// **NOTE:** This requires the `wrap_help` feature
@@ -1158,7 +1166,9 @@ impl Command {
/// This only applies when [`term_width`][Command::term_width] is unset so that the current
/// terminal's width will be used. See [`Command::term_width`] for more details.
///
- /// Using `0` will ignore terminal widths and use source formatting (default).
+ /// Using `0` will ignore this, always respecting [`Command::term_width`] (default).
+ ///
+ /// **`unstable-v5` feature**: Defaults to 100.
///
/// **NOTE:** This setting applies globally and *not* on a per-command basis.
///
diff --git a/vendor/clap_builder/src/builder/debug_asserts.rs b/vendor/clap_builder/src/builder/debug_asserts.rs
index ef970cdaa..29008be9f 100644
--- a/vendor/clap_builder/src/builder/debug_asserts.rs
+++ b/vendor/clap_builder/src/builder/debug_asserts.rs
@@ -1,8 +1,5 @@
use std::cmp::Ordering;
-use clap_lex::OsStrExt as _;
-
-use crate::builder::OsStr;
use crate::builder::ValueRange;
use crate::mkeymap::KeyType;
use crate::util::FlatSet;
@@ -809,20 +806,6 @@ fn assert_arg(arg: &Arg) {
}
assert_arg_flags(arg);
-
- assert_defaults(arg, "default_value", arg.default_vals.iter());
- assert_defaults(
- arg,
- "default_missing_value",
- arg.default_missing_vals.iter(),
- );
- assert_defaults(
- arg,
- "default_value_if",
- arg.default_vals_ifs
- .iter()
- .filter_map(|(_, _, default)| default.as_ref()),
- );
}
fn assert_arg_flags(arg: &Arg) {
@@ -854,37 +837,3 @@ fn assert_arg_flags(arg: &Arg) {
checker!(is_multiple_values_set requires is_takes_value_set);
checker!(is_ignore_case_set requires is_takes_value_set);
}
-
-fn assert_defaults<'d>(
- arg: &Arg,
- field: &'static str,
- defaults: impl IntoIterator<Item = &'d OsStr>,
-) {
- for default_os in defaults {
- let value_parser = arg.get_value_parser();
- let assert_cmd = Command::new("assert");
- if let Some(val_delim) = arg.get_value_delimiter() {
- let mut val_delim_buffer = [0; 4];
- let val_delim = val_delim.encode_utf8(&mut val_delim_buffer);
- for part in default_os.split(val_delim) {
- if let Err(err) = value_parser.parse_ref(&assert_cmd, Some(arg), part) {
- panic!(
- "Argument `{}`'s {}={:?} failed validation: {}",
- arg.get_id(),
- field,
- part.to_string_lossy(),
- err
- );
- }
- }
- } else if let Err(err) = value_parser.parse_ref(&assert_cmd, Some(arg), default_os) {
- panic!(
- "Argument `{}`'s {}={:?} failed validation: {}",
- arg.get_id(),
- field,
- default_os,
- err
- );
- }
- }
-}
diff --git a/vendor/clap_builder/src/builder/mod.rs b/vendor/clap_builder/src/builder/mod.rs
index 495c84587..ad70911a9 100644
--- a/vendor/clap_builder/src/builder/mod.rs
+++ b/vendor/clap_builder/src/builder/mod.rs
@@ -23,6 +23,11 @@ mod debug_asserts;
#[cfg(test)]
mod tests;
+#[cfg(feature = "unstable-styles")]
+pub mod styling;
+#[cfg(not(feature = "unstable-styles"))]
+pub(crate) mod styling;
+
pub use self::str::Str;
pub use action::ArgAction;
pub use arg::Arg;
@@ -36,7 +41,7 @@ pub use resettable::IntoResettable;
pub use resettable::Resettable;
pub use styled_str::StyledStr;
#[cfg(feature = "unstable-styles")]
-pub use styled_str::Styles;
+pub use styling::Styles;
pub use value_hint::ValueHint;
pub use value_parser::_AutoValueParser;
pub use value_parser::via_prelude;
@@ -63,4 +68,4 @@ pub(crate) use action::CountType;
pub(crate) use arg_settings::{ArgFlags, ArgSettings};
pub(crate) use command::AppTag;
#[cfg(not(feature = "unstable-styles"))]
-pub(crate) use styled_str::Styles;
+pub(crate) use styling::Styles;
diff --git a/vendor/clap_builder/src/builder/styled_str.rs b/vendor/clap_builder/src/builder/styled_str.rs
index e4acc63ff..d856a3015 100644
--- a/vendor/clap_builder/src/builder/styled_str.rs
+++ b/vendor/clap_builder/src/builder/styled_str.rs
@@ -197,164 +197,3 @@ impl std::fmt::Display for StyledStr {
Ok(())
}
}
-
-/// Terminal styling definitions
-#[derive(Clone, Debug)]
-#[allow(missing_copy_implementations)] // Large enough type that I want an explicit `clone()` for now
-pub struct Styles {
- header: anstyle::Style,
- error: anstyle::Style,
- usage: anstyle::Style,
- literal: anstyle::Style,
- placeholder: anstyle::Style,
- valid: anstyle::Style,
- invalid: anstyle::Style,
-}
-
-impl Styles {
- /// No terminal styling
- pub const fn plain() -> Self {
- Self {
- header: anstyle::Style::new(),
- error: anstyle::Style::new(),
- usage: anstyle::Style::new(),
- literal: anstyle::Style::new(),
- placeholder: anstyle::Style::new(),
- valid: anstyle::Style::new(),
- invalid: anstyle::Style::new(),
- }
- }
-
- /// Default terminal styling
- pub const fn styled() -> Self {
- #[cfg(feature = "color")]
- {
- Self {
- header: anstyle::Style::new().bold().underline(),
- error: anstyle::Style::new()
- .fg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::Red)))
- .bold(),
- usage: anstyle::Style::new().bold().underline(),
- literal: anstyle::Style::new().bold(),
- placeholder: anstyle::Style::new(),
- valid: anstyle::Style::new()
- .fg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::Green))),
- invalid: anstyle::Style::new()
- .fg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::Yellow))),
- }
- }
- #[cfg(not(feature = "color"))]
- {
- Self::plain()
- }
- }
-
- /// General Heading style, e.g. [`help_heading`][crate::Arg::help_heading]
- #[inline]
- pub const fn header(mut self, style: anstyle::Style) -> Self {
- self.header = style;
- self
- }
-
- /// Error heading
- #[inline]
- pub const fn error(mut self, style: anstyle::Style) -> Self {
- self.error = style;
- self
- }
-
- /// Usage heading
- #[inline]
- pub const fn usage(mut self, style: anstyle::Style) -> Self {
- self.usage = style;
- self
- }
-
- /// Literal command-line syntax, e.g. `--help`
- #[inline]
- pub const fn literal(mut self, style: anstyle::Style) -> Self {
- self.literal = style;
- self
- }
-
- /// Descriptions within command-line syntax, e.g. [`value_name`][crate::Arg::value_name]
- #[inline]
- pub const fn placeholder(mut self, style: anstyle::Style) -> Self {
- self.placeholder = style;
- self
- }
-
- /// Highlight suggested usage
- #[inline]
- pub const fn valid(mut self, style: anstyle::Style) -> Self {
- self.valid = style;
- self
- }
-
- /// Highlight invalid usage
- #[inline]
- pub const fn invalid(mut self, style: anstyle::Style) -> Self {
- self.invalid = style;
- self
- }
-}
-
-/// Reflection
-impl Styles {
- /// General Heading style, e.g. [`help_heading`][crate::Arg::help_heading]
- #[inline(always)]
- pub const fn get_header(&self) -> &anstyle::Style {
- &self.header
- }
-
- /// Error heading
- #[inline(always)]
- pub const fn get_error(&self) -> &anstyle::Style {
- &self.error
- }
-
- /// Usage heading
- #[inline(always)]
- pub const fn get_usage(&self) -> &anstyle::Style {
- &self.usage
- }
-
- /// Literal command-line syntax, e.g. `--help`
- #[inline(always)]
- pub const fn get_literal(&self) -> &anstyle::Style {
- &self.literal
- }
-
- /// Descriptions within command-line syntax, e.g. [`value_name`][crate::Arg::value_name]
- #[inline(always)]
- pub const fn get_placeholder(&self) -> &anstyle::Style {
- &self.placeholder
- }
-
- /// Highlight suggested usage
- #[inline(always)]
- pub const fn get_valid(&self) -> &anstyle::Style {
- &self.valid
- }
-
- /// Highlight invalid usage
- #[inline(always)]
- pub const fn get_invalid(&self) -> &anstyle::Style {
- &self.invalid
- }
-}
-
-impl super::AppTag for Styles {}
-
-impl Default for Styles {
- fn default() -> Self {
- Self::styled()
- }
-}
-
-impl Default for &'_ Styles {
- fn default() -> Self {
- const STYLES: Styles = Styles::styled();
- &STYLES
- }
-}
diff --git a/vendor/clap_builder/src/builder/styling.rs b/vendor/clap_builder/src/builder/styling.rs
new file mode 100644
index 000000000..f7f2ee1e3
--- /dev/null
+++ b/vendor/clap_builder/src/builder/styling.rs
@@ -0,0 +1,181 @@
+//! Terminal [`Styles`] for help and error output
+
+pub use anstyle::*;
+
+/// Terminal styling definitions
+///
+/// See also [`Command::styles`][crate::Command::styles].
+///
+/// # Example
+///
+/// clap v3 styling
+/// ```rust
+/// # #[cfg(feature = "unstable-styles")] {
+/// # use clap_builder as clap;
+/// # use clap::builder::styling::*;
+/// let styles = Styles::styled()
+/// .header(AnsiColor::Yellow.on_default())
+/// .usage(AnsiColor::Green.on_default())
+/// .literal(AnsiColor::Green.on_default())
+/// .placeholder(AnsiColor::Green.on_default());
+/// # }
+/// ```
+#[derive(Clone, Debug)]
+#[allow(missing_copy_implementations)] // Large enough type that I want an explicit `clone()` for now
+pub struct Styles {
+ header: anstyle::Style,
+ error: anstyle::Style,
+ usage: anstyle::Style,
+ literal: anstyle::Style,
+ placeholder: anstyle::Style,
+ valid: anstyle::Style,
+ invalid: anstyle::Style,
+}
+
+impl Styles {
+ /// No terminal styling
+ pub const fn plain() -> Self {
+ Self {
+ header: anstyle::Style::new(),
+ error: anstyle::Style::new(),
+ usage: anstyle::Style::new(),
+ literal: anstyle::Style::new(),
+ placeholder: anstyle::Style::new(),
+ valid: anstyle::Style::new(),
+ invalid: anstyle::Style::new(),
+ }
+ }
+
+ /// Default terminal styling
+ pub const fn styled() -> Self {
+ #[cfg(feature = "color")]
+ {
+ Self {
+ header: anstyle::Style::new().bold().underline(),
+ error: anstyle::Style::new()
+ .fg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::Red)))
+ .bold(),
+ usage: anstyle::Style::new().bold().underline(),
+ literal: anstyle::Style::new().bold(),
+ placeholder: anstyle::Style::new(),
+ valid: anstyle::Style::new()
+ .fg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::Green))),
+ invalid: anstyle::Style::new()
+ .fg_color(Some(anstyle::Color::Ansi(anstyle::AnsiColor::Yellow))),
+ }
+ }
+ #[cfg(not(feature = "color"))]
+ {
+ Self::plain()
+ }
+ }
+
+ /// General Heading style, e.g. [`help_heading`][crate::Arg::help_heading]
+ #[inline]
+ pub const fn header(mut self, style: anstyle::Style) -> Self {
+ self.header = style;
+ self
+ }
+
+ /// Error heading
+ #[inline]
+ pub const fn error(mut self, style: anstyle::Style) -> Self {
+ self.error = style;
+ self
+ }
+
+ /// Usage heading
+ #[inline]
+ pub const fn usage(mut self, style: anstyle::Style) -> Self {
+ self.usage = style;
+ self
+ }
+
+ /// Literal command-line syntax, e.g. `--help`
+ #[inline]
+ pub const fn literal(mut self, style: anstyle::Style) -> Self {
+ self.literal = style;
+ self
+ }
+
+ /// Descriptions within command-line syntax, e.g. [`value_name`][crate::Arg::value_name]
+ #[inline]
+ pub const fn placeholder(mut self, style: anstyle::Style) -> Self {
+ self.placeholder = style;
+ self
+ }
+
+ /// Highlight suggested usage
+ #[inline]
+ pub const fn valid(mut self, style: anstyle::Style) -> Self {
+ self.valid = style;
+ self
+ }
+
+ /// Highlight invalid usage
+ #[inline]
+ pub const fn invalid(mut self, style: anstyle::Style) -> Self {
+ self.invalid = style;
+ self
+ }
+}
+
+/// Reflection
+impl Styles {
+ /// General Heading style, e.g. [`help_heading`][crate::Arg::help_heading]
+ #[inline(always)]
+ pub const fn get_header(&self) -> &anstyle::Style {
+ &self.header
+ }
+
+ /// Error heading
+ #[inline(always)]
+ pub const fn get_error(&self) -> &anstyle::Style {
+ &self.error
+ }
+
+ /// Usage heading
+ #[inline(always)]
+ pub const fn get_usage(&self) -> &anstyle::Style {
+ &self.usage
+ }
+
+ /// Literal command-line syntax, e.g. `--help`
+ #[inline(always)]
+ pub const fn get_literal(&self) -> &anstyle::Style {
+ &self.literal
+ }
+
+ /// Descriptions within command-line syntax, e.g. [`value_name`][crate::Arg::value_name]
+ #[inline(always)]
+ pub const fn get_placeholder(&self) -> &anstyle::Style {
+ &self.placeholder
+ }
+
+ /// Highlight suggested usage
+ #[inline(always)]
+ pub const fn get_valid(&self) -> &anstyle::Style {
+ &self.valid
+ }
+
+ /// Highlight invalid usage
+ #[inline(always)]
+ pub const fn get_invalid(&self) -> &anstyle::Style {
+ &self.invalid
+ }
+}
+
+impl super::AppTag for Styles {}
+
+impl Default for Styles {
+ fn default() -> Self {
+ Self::styled()
+ }
+}
+
+impl Default for &'_ Styles {
+ fn default() -> Self {
+ const STYLES: Styles = Styles::styled();
+ &STYLES
+ }
+}
diff --git a/vendor/clap_builder/src/builder/value_parser.rs b/vendor/clap_builder/src/builder/value_parser.rs
index 4b0955789..c7c7e61eb 100644
--- a/vendor/clap_builder/src/builder/value_parser.rs
+++ b/vendor/clap_builder/src/builder/value_parser.rs
@@ -2137,18 +2137,38 @@ impl ValueParserFactory for String {
ValueParser::string() // Default `clap_derive` to optimized implementation
}
}
+impl ValueParserFactory for Box<str> {
+ type Parser = MapValueParser<StringValueParser, fn(String) -> Box<str>>;
+ fn value_parser() -> Self::Parser {
+ StringValueParser::new().map(String::into_boxed_str)
+ }
+}
impl ValueParserFactory for std::ffi::OsString {
type Parser = ValueParser;
fn value_parser() -> Self::Parser {
ValueParser::os_string() // Default `clap_derive` to optimized implementation
}
}
+impl ValueParserFactory for Box<std::ffi::OsStr> {
+ type Parser =
+ MapValueParser<OsStringValueParser, fn(std::ffi::OsString) -> Box<std::ffi::OsStr>>;
+ fn value_parser() -> Self::Parser {
+ OsStringValueParser::new().map(std::ffi::OsString::into_boxed_os_str)
+ }
+}
impl ValueParserFactory for std::path::PathBuf {
type Parser = ValueParser;
fn value_parser() -> Self::Parser {
ValueParser::path_buf() // Default `clap_derive` to optimized implementation
}
}
+impl ValueParserFactory for Box<std::path::Path> {
+ type Parser =
+ MapValueParser<PathBufValueParser, fn(std::path::PathBuf) -> Box<std::path::Path>>;
+ fn value_parser() -> Self::Parser {
+ PathBufValueParser::new().map(std::path::PathBuf::into_boxed_path)
+ }
+}
impl ValueParserFactory for bool {
type Parser = ValueParser;
fn value_parser() -> Self::Parser {
@@ -2203,16 +2223,49 @@ impl ValueParserFactory for i32 {
RangedI64ValueParser::new().range(start..=end)
}
}
+impl ValueParserFactory for u64 {
+ type Parser = RangedU64ValueParser<u64>;
+ fn value_parser() -> Self::Parser {
+ RangedU64ValueParser::new()
+ }
+}
impl ValueParserFactory for i64 {
type Parser = RangedI64ValueParser<i64>;
fn value_parser() -> Self::Parser {
RangedI64ValueParser::new()
}
}
-impl ValueParserFactory for u64 {
- type Parser = RangedU64ValueParser<u64>;
+impl<T> ValueParserFactory for std::num::Wrapping<T>
+where
+ T: ValueParserFactory,
+ <T as ValueParserFactory>::Parser: TypedValueParser<Value = T>,
+ T: Send + Sync + Clone,
+{
+ type Parser = MapValueParser<<T as ValueParserFactory>::Parser, fn(T) -> std::num::Wrapping<T>>;
fn value_parser() -> Self::Parser {
- RangedU64ValueParser::new()
+ T::value_parser().map(std::num::Wrapping)
+ }
+}
+impl<T> ValueParserFactory for Box<T>
+where
+ T: ValueParserFactory,
+ <T as ValueParserFactory>::Parser: TypedValueParser<Value = T>,
+ T: Send + Sync + Clone,
+{
+ type Parser = MapValueParser<<T as ValueParserFactory>::Parser, fn(T) -> Box<T>>;
+ fn value_parser() -> Self::Parser {
+ T::value_parser().map(Box::new)
+ }
+}
+impl<T> ValueParserFactory for std::sync::Arc<T>
+where
+ T: ValueParserFactory,
+ <T as ValueParserFactory>::Parser: TypedValueParser<Value = T>,
+ T: Send + Sync + Clone,
+{
+ type Parser = MapValueParser<<T as ValueParserFactory>::Parser, fn(T) -> std::sync::Arc<T>>;
+ fn value_parser() -> Self::Parser {
+ T::value_parser().map(std::sync::Arc::new)
}
}
diff --git a/vendor/clap_builder/src/error/mod.rs b/vendor/clap_builder/src/error/mod.rs
index 210a1717f..772058a5f 100644
--- a/vendor/clap_builder/src/error/mod.rs
+++ b/vendor/clap_builder/src/error/mod.rs
@@ -446,6 +446,7 @@ impl<F: ErrorFormatter> Error<F> {
subcmd: String,
did_you_mean: Vec<String>,
name: String,
+ suggested_trailing_arg: bool,
usage: Option<StyledStr>,
) -> Self {
use std::fmt::Write as _;
@@ -456,15 +457,19 @@ impl<F: ErrorFormatter> Error<F> {
#[cfg(feature = "error-context")]
{
- let mut styled_suggestion = StyledStr::new();
- let _ = write!(
- styled_suggestion,
- "to pass '{}{subcmd}{}' as a value, use '{}{name} -- {subcmd}{}'",
- invalid.render(),
- invalid.render_reset(),
- valid.render(),
- valid.render_reset()
- );
+ let mut suggestions = vec![];
+ if suggested_trailing_arg {
+ let mut styled_suggestion = StyledStr::new();
+ let _ = write!(
+ styled_suggestion,
+ "to pass '{}{subcmd}{}' as a value, use '{}{name} -- {subcmd}{}'",
+ invalid.render(),
+ invalid.render_reset(),
+ valid.render(),
+ valid.render_reset()
+ );
+ suggestions.push(styled_suggestion);
+ }
err = err.extend_context_unchecked([
(ContextKind::InvalidSubcommand, ContextValue::String(subcmd)),
@@ -474,7 +479,7 @@ impl<F: ErrorFormatter> Error<F> {
),
(
ContextKind::Suggested,
- ContextValue::StyledStrs(vec![styled_suggestion]),
+ ContextValue::StyledStrs(suggestions),
),
]);
if let Some(usage) = usage {
diff --git a/vendor/clap_builder/src/output/help_template.rs b/vendor/clap_builder/src/output/help_template.rs
index 68ff58077..da2e75413 100644
--- a/vendor/clap_builder/src/output/help_template.rs
+++ b/vendor/clap_builder/src/output/help_template.rs
@@ -101,7 +101,23 @@ impl<'cmd, 'writer> HelpTemplate<'cmd, 'writer> {
cmd.get_name(),
use_long
);
- let term_w = match cmd.get_term_width() {
+ let term_w = Self::term_w(cmd);
+ let next_line_help = cmd.is_next_line_help_set();
+
+ HelpTemplate {
+ writer,
+ cmd,
+ styles: cmd.get_styles(),
+ usage,
+ next_line_help,
+ term_w,
+ use_long,
+ }
+ }
+
+ #[cfg(not(feature = "unstable-v5"))]
+ fn term_w(cmd: &'cmd Command) -> usize {
+ match cmd.get_term_width() {
Some(0) => usize::MAX,
Some(w) => w,
None => {
@@ -113,18 +129,27 @@ impl<'cmd, 'writer> HelpTemplate<'cmd, 'writer> {
};
cmp::min(current_width, max_width)
}
+ }
+ }
+
+ #[cfg(feature = "unstable-v5")]
+ fn term_w(cmd: &'cmd Command) -> usize {
+ let term_w = match cmd.get_term_width() {
+ Some(0) => usize::MAX,
+ Some(w) => w,
+ None => {
+ let (current_width, _h) = dimensions();
+ current_width.unwrap_or(usize::MAX)
+ }
};
- let next_line_help = cmd.is_next_line_help_set();
- HelpTemplate {
- writer,
- cmd,
- styles: cmd.get_styles(),
- usage,
- next_line_help,
- term_w,
- use_long,
- }
+ let max_term_w = match cmd.get_max_term_width() {
+ Some(0) => usize::MAX,
+ Some(mw) => mw,
+ None => 100,
+ };
+
+ cmp::min(term_w, max_term_w)
}
/// Write help to stream for the parser in the format defined by the template.
@@ -676,32 +701,33 @@ impl<'cmd, 'writer> HelpTemplate<'cmd, 'writer> {
self.writer.push_str("Possible values:");
for pv in possible_vals.iter().filter(|pv| !pv.is_hide_set()) {
let name = pv.get_name();
+
+ let mut descr = StyledStr::new();
let _ = write!(
- self.writer,
- "\n{:spaces$}- {}{name}{}",
- "",
+ &mut descr,
+ "{}{name}{}",
literal.render(),
literal.render_reset()
);
if let Some(help) = pv.get_help() {
debug!("HelpTemplate::help: Possible Value help");
-
// To align help messages
- let padding = longest - display_width(pv.get_name());
- let _ = write!(self.writer, ": {:padding$}", "");
-
- let avail_chars = if self.term_w > trailing_indent.len() {
- self.term_w - trailing_indent.len()
- } else {
- usize::MAX
- };
-
- let mut help = help.clone();
- help.replace_newline_var();
- help.wrap(avail_chars);
- help.indent("", &trailing_indent);
- self.writer.push_styled(&help);
+ let padding = longest - display_width(name);
+ let _ = write!(&mut descr, ": {:padding$}", "");
+ descr.push_styled(help);
}
+
+ let avail_chars = if self.term_w > trailing_indent.len() {
+ self.term_w - trailing_indent.len()
+ } else {
+ usize::MAX
+ };
+ descr.replace_newline_var();
+ descr.wrap(avail_chars);
+ descr.indent("", &trailing_indent);
+
+ let _ = write!(self.writer, "\n{:spaces$}- ", "",);
+ self.writer.push_styled(&descr);
}
}
}
diff --git a/vendor/clap_builder/src/output/usage.rs b/vendor/clap_builder/src/output/usage.rs
index 3f387a0d7..884a64df9 100644
--- a/vendor/clap_builder/src/output/usage.rs
+++ b/vendor/clap_builder/src/output/usage.rs
@@ -4,6 +4,7 @@
#![cfg_attr(not(feature = "usage"), allow(dead_code))]
// Internal
+use crate::builder::ArgAction;
use crate::builder::StyledStr;
use crate::builder::Styles;
use crate::builder::{ArgPredicate, Command};
@@ -210,6 +211,20 @@ impl<'cmd> Usage<'cmd> {
debug!("Usage::needs_options_tag:iter Option is built-in");
continue;
}
+ match f.get_action() {
+ ArgAction::Set
+ | ArgAction::Append
+ | ArgAction::SetTrue
+ | ArgAction::SetFalse
+ | ArgAction::Count => {}
+ ArgAction::Help
+ | ArgAction::HelpShort
+ | ArgAction::HelpLong
+ | ArgAction::Version => {
+ debug!("Usage::needs_options_tag:iter Option is built-in");
+ continue;
+ }
+ }
if f.is_hide_set() {
debug!("Usage::needs_options_tag:iter Option is hidden");
diff --git a/vendor/clap_builder/src/parser/parser.rs b/vendor/clap_builder/src/parser/parser.rs
index d2e198b28..d6d8e8da4 100644
--- a/vendor/clap_builder/src/parser/parser.rs
+++ b/vendor/clap_builder/src/parser/parser.rs
@@ -302,6 +302,13 @@ impl<'cmd> Parser<'cmd> {
.map(|p_name| !p_name.is_last_set())
.unwrap_or_default();
+ let is_terminated = self
+ .cmd
+ .get_keymap()
+ .get(&pos_counter)
+ .map(|a| a.get_value_terminator().is_some())
+ .unwrap_or_default();
+
let missing_pos = self.cmd.is_allow_missing_positional_set()
&& is_second_to_last
&& !trailing_values;
@@ -309,7 +316,7 @@ impl<'cmd> Parser<'cmd> {
debug!("Parser::get_matches_with: Positional counter...{pos_counter}");
debug!("Parser::get_matches_with: Low index multiples...{low_index_mults:?}");
- if low_index_mults || missing_pos {
+ if (low_index_mults || missing_pos) && !is_terminated {
let skip_current = if let Some(n) = raw_args.peek(&args_cursor) {
if let Some(arg) = self
.cmd
@@ -474,6 +481,10 @@ impl<'cmd> Parser<'cmd> {
}
}
+ let suggested_trailing_arg = !trailing_values
+ && self.cmd.has_positionals()
+ && (arg_os.is_long() || arg_os.is_short());
+
if !(self.cmd.is_args_conflicts_with_subcommands_set() && valid_arg_found) {
let candidates = suggestions::did_you_mean(
&arg_os.display().to_string(),
@@ -489,6 +500,7 @@ impl<'cmd> Parser<'cmd> {
.get_bin_name()
.unwrap_or_else(|| self.cmd.get_name())
.to_owned(),
+ suggested_trailing_arg,
Usage::new(self.cmd).create_usage_with_title(&[]),
);
}
@@ -505,9 +517,6 @@ impl<'cmd> Parser<'cmd> {
}
}
- let suggested_trailing_arg = !trailing_values
- && self.cmd.has_positionals()
- && (arg_os.is_long() || arg_os.is_short());
ClapError::unknown_argument(
self.cmd,
arg_os.display().to_string(),
@@ -1237,6 +1246,16 @@ impl<'cmd> Parser<'cmd> {
debug!("Help: use_long={use_long}");
Err(self.help_err(use_long))
}
+ ArgAction::HelpShort => {
+ let use_long = false;
+ debug!("Help: use_long={use_long}");
+ Err(self.help_err(use_long))
+ }
+ ArgAction::HelpLong => {
+ let use_long = true;
+ debug!("Help: use_long={use_long}");
+ Err(self.help_err(use_long))
+ }
ArgAction::Version => {
let use_long = match ident {
Some(Identifier::Long) => true,