mirror of
https://github.com/gay-pizza/jaarg.git
synced 2025-12-19 07:20:18 +00:00
Restrict scope of automatic usage hint in standard error writer, so the default behaviour is less spammy
This commit is contained in:
@@ -209,19 +209,22 @@ impl<ID> core::fmt::Display for StandardErrorUsageWriter<'_, ID> {
|
||||
// Write error
|
||||
writeln!(f, "{name}: {error}", name=self.0.program_name, error = self.0.error)?;
|
||||
|
||||
// Write usage
|
||||
// Provide usage hint for missing required arguments
|
||||
if matches!(self.0.error, ParseError::RequiredPositional(_) | ParseError::RequiredParameter(_)) {
|
||||
// Write short usage
|
||||
writeln!(f, "{}", StandardShortUsageWriter::new(HelpWriterContext {
|
||||
options: self.0.options,
|
||||
program_name: self.0.program_name
|
||||
}))?;
|
||||
|
||||
// Write full help instruction if a
|
||||
// Write full help instruction if available
|
||||
if let Some(help_option) = self.0.options.help_option() {
|
||||
writeln!(f, "Run '{name} {help}' to view all available options.",
|
||||
name = self.0.program_name,
|
||||
// Prefer long name, but otherwise any name is fine
|
||||
help = help_option.first_long_name().unwrap_or(help_option.first_name()))?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user