-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make get_full_help
take &dyn Command
#12903
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a good simplification to me. How does this affect custom subcommands? Are they applied correctly (since they seem to not use the Command
paradigm in a few ways)
It looks like custom sub commands like I believe the only quick with custom commands is that they can't be run directly with |
let b_distance = levenshtein_distance(line, &b.name); | ||
a_distance.cmp(&b_distance) | ||
}); | ||
commands.sort_by_cached_key(|decl| levenshtein_distance(line, decl.name())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds clever
&self, | ||
include_hidden: bool, | ||
) -> impl Iterator<Item = (Vec<u8>, DeclId)> { | ||
pub fn get_decls_sorted(&self, include_hidden: bool) -> Vec<(Vec<u8>, DeclId)> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense with the current implementation, if we have to allocate for the deduping and sorting anyways.
(the question if HashMap
then Vec
sort beats out the BTreeMap
is one of those "what is the real data you run it with anyways" perf questions)
Description
Changes
get_full_help
to take a&dyn Command
instead of multiple arguments (&Signature
,&Examples
is_parser_keyword
). All of these arguments can be gathered from aCommand
, so there is no need to pass the pieces toget_full_help
.This PR also fixes an issue where the search terms are not shown if
--help
is used on a command.