summaryrefslogtreecommitdiff
path: root/vendor/clap_builder/src/output/help.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
committerValentin Popov <valentin@popov.link>2024-01-08 00:21:28 +0300
commit1b6a04ca5504955c571d1c97504fb45ea0befee4 (patch)
tree7579f518b23313e8a9748a88ab6173d5e030b227 /vendor/clap_builder/src/output/help.rs
parent5ecd8cf2cba827454317368b68571df0d13d7842 (diff)
downloadfparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.tar.xz
fparkan-1b6a04ca5504955c571d1c97504fb45ea0befee4.zip
Initial vendor packages
Signed-off-by: Valentin Popov <valentin@popov.link>
Diffstat (limited to 'vendor/clap_builder/src/output/help.rs')
-rw-r--r--vendor/clap_builder/src/output/help.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/vendor/clap_builder/src/output/help.rs b/vendor/clap_builder/src/output/help.rs
new file mode 100644
index 0000000..a5073a9
--- /dev/null
+++ b/vendor/clap_builder/src/output/help.rs
@@ -0,0 +1,39 @@
+#![cfg_attr(not(feature = "help"), allow(unused_variables))]
+
+// Internal
+use crate::builder::Command;
+use crate::builder::StyledStr;
+use crate::output::Usage;
+
+/// Writes the parser help to the wrapped stream.
+pub(crate) fn write_help(writer: &mut StyledStr, cmd: &Command, usage: &Usage<'_>, use_long: bool) {
+ debug!("write_help");
+
+ if let Some(h) = cmd.get_override_help() {
+ writer.push_styled(h);
+ } else {
+ #[cfg(feature = "help")]
+ {
+ use super::AutoHelp;
+ use super::HelpTemplate;
+ if let Some(tmpl) = cmd.get_help_template() {
+ HelpTemplate::new(writer, cmd, usage, use_long)
+ .write_templated_help(tmpl.as_styled_str());
+ } else {
+ AutoHelp::new(writer, cmd, usage, use_long).write_help();
+ }
+ }
+
+ #[cfg(not(feature = "help"))]
+ {
+ debug!("write_help: no help, `Command::override_help` and `help` is missing");
+ }
+ }
+
+ // Remove any lines from unused sections
+ writer.trim_start_lines();
+ // Remove any whitespace caused by book keeping
+ writer.trim_end();
+ // Ensure there is still a trailing newline
+ writer.push_str("\n");
+}