blob: 98ca91b19b0cb7e41371fc13b2ca1b63ffb9e2a0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
//! ref: composer/vendor/symfony/console/Completion/Output/BashCompletionOutput.php
use crate::completion::CompletionOutputInterface;
use crate::completion::CompletionSuggestions;
use crate::output::OutputInterface;
#[derive(Debug)]
pub struct BashCompletionOutput;
impl CompletionOutputInterface for BashCompletionOutput {
fn write(&self, suggestions: &CompletionSuggestions, output: &dyn OutputInterface) {
let mut values: Vec<String> = suggestions
.get_value_suggestions()
.iter()
.map(|suggestion| suggestion.get_value())
.collect();
for option in suggestions.get_option_suggestions() {
values.push(format!("--{}", option.get_name()));
if option.is_negatable() {
values.push(format!("--no-{}", option.get_name()));
}
}
output.writeln(&[values.join("\n")], 0);
}
}
|