Add command descriptions to completions (#5063)
This commit is contained in:
parent
19c3570cf9
commit
80c9888f82
|
@ -150,8 +150,8 @@ impl NuCompleter {
|
||||||
.find_commands_by_prefix(prefix)
|
.find_commands_by_prefix(prefix)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(move |x| Suggestion {
|
.map(move |x| Suggestion {
|
||||||
value: String::from_utf8_lossy(&x).to_string(),
|
value: String::from_utf8_lossy(&x.0).to_string(),
|
||||||
description: None,
|
description: x.1,
|
||||||
span: reedline::Span {
|
span: reedline::Span {
|
||||||
start: span.start - offset,
|
start: span.start - offset,
|
||||||
end: span.end - offset,
|
end: span.end - offset,
|
||||||
|
|
|
@ -443,13 +443,14 @@ impl EngineState {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn find_commands_by_prefix(&self, name: &[u8]) -> Vec<Vec<u8>> {
|
pub fn find_commands_by_prefix(&self, name: &[u8]) -> Vec<(Vec<u8>, Option<String>)> {
|
||||||
let mut output = vec![];
|
let mut output = vec![];
|
||||||
|
|
||||||
for scope in self.scope.iter().rev() {
|
for scope in self.scope.iter().rev() {
|
||||||
for decl in &scope.decls {
|
for decl in &scope.decls {
|
||||||
if decl.0.starts_with(name) {
|
if decl.0.starts_with(name) {
|
||||||
output.push(decl.0.clone());
|
let command = self.get_decl(*decl.1);
|
||||||
|
output.push((decl.0.clone(), Some(command.usage().to_string())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1296,13 +1297,14 @@ impl<'a> StateWorkingSet<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn find_commands_by_prefix(&self, name: &[u8]) -> Vec<Vec<u8>> {
|
pub fn find_commands_by_prefix(&self, name: &[u8]) -> Vec<(Vec<u8>, Option<String>)> {
|
||||||
let mut output = vec![];
|
let mut output = vec![];
|
||||||
|
|
||||||
for scope in self.delta.scope.iter().rev() {
|
for scope in self.delta.scope.iter().rev() {
|
||||||
for decl in &scope.decls {
|
for decl in &scope.decls {
|
||||||
if decl.0.starts_with(name) {
|
if decl.0.starts_with(name) {
|
||||||
output.push(decl.0.clone());
|
let command = self.get_decl(*decl.1);
|
||||||
|
output.push((decl.0.clone(), Some(command.usage().to_string())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user