Skip to content

Commit

Permalink
feat(builder): Expose get_display_order
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Sep 20, 2024
1 parent 67d9fef commit c6b5d62
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
11 changes: 6 additions & 5 deletions clap_builder/src/builder/arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3870,6 +3870,12 @@ impl Arg {
self.long_help.as_ref()
}

/// Get the placement within help
#[inline]
pub fn get_display_order(&self) -> usize {
self.disp_ord.unwrap_or(999)
}

/// Get the help heading specified for this argument, if any
#[inline]
pub fn get_help_heading(&self) -> Option<&str> {
Expand Down Expand Up @@ -4422,11 +4428,6 @@ impl Arg {
pub(crate) fn is_multiple(&self) -> bool {
self.is_multiple_values_set() || matches!(*self.get_action(), ArgAction::Append)
}

#[cfg(feature = "help")]
pub(crate) fn get_display_order(&self) -> usize {
self.disp_ord.unwrap_or(999)
}
}

impl From<&'_ Arg> for Arg {
Expand Down
11 changes: 6 additions & 5 deletions clap_builder/src/builder/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3462,6 +3462,12 @@ impl Command {
self.long_version.as_deref()
}

/// Get the placement within help
#[inline]
pub fn get_display_order(&self) -> usize {
self.disp_ord.unwrap_or(999)
}

/// Get the authors of the cmd.
#[inline]
pub fn get_author(&self) -> Option<&str> {
Expand Down Expand Up @@ -4777,11 +4783,6 @@ impl Command {
.map(|sc| sc.get_name())
}

#[cfg(feature = "help")]
pub(crate) fn get_display_order(&self) -> usize {
self.disp_ord.unwrap_or(999)
}

pub(crate) fn write_help_err(&self, mut use_long: bool) -> StyledStr {
debug!(
"Command::write_help_err: {}, use_long={:?}",
Expand Down

0 comments on commit c6b5d62

Please sign in to comment.