Skip to content

Commit b183e2c

Browse files
ericktCQ Bot
authored andcommitted
[rust-3p] Update rustyline to 15.0.0
This also: * stubs out cfg_aliases 0.2.1 * stubs out clipboard-win * stubs out windows-sys 0.59.0 * bumps the stubbed out windows-targets to 0.52.6 Change-Id: Ie020074a3957f1d0e3b96317465681d215fa25a7 Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1186075 Reviewed-by: Marie Janssen <[email protected]> Commit-Queue: Auto-Submit <[email protected]> Reviewed-by: David Koloski <[email protected]> Reviewed-by: Marco Vanotti <[email protected]> Reviewed-by: Justin Mattson <[email protected]> Reviewed-by: Vaas Krishnamurthy <[email protected]> Reviewed-by: Erick Tryzelaar <[email protected]> Reviewed-by: Prashanth Swaminathan <[email protected]> Fuchsia-Auto-Submit: Erick Tryzelaar <[email protected]>
1 parent f56fb4f commit b183e2c

File tree

213 files changed

+15378
-51633
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

213 files changed

+15378
-51633
lines changed

src/connectivity/bluetooth/tools/bt-avdtp-tool/src/commands.rs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ use rustyline::completion::Completer;
66
use rustyline::error::ReadlineError;
77
use rustyline::highlight::Highlighter;
88
use rustyline::hint::Hinter;
9-
use rustyline::Helper;
9+
use rustyline::validate::Validator;
10+
use rustyline::{Context, Helper};
1011
use std::borrow::Cow::{self, Borrowed, Owned};
1112
use std::fmt;
1213
use std::str::FromStr;
@@ -111,7 +112,12 @@ impl CmdHelper {
111112
impl Completer for CmdHelper {
112113
type Candidate = String;
113114

114-
fn complete(&self, line: &str, _pos: usize) -> Result<(usize, Vec<String>), ReadlineError> {
115+
fn complete(
116+
&self,
117+
line: &str,
118+
_pos: usize,
119+
_context: &Context<'_>,
120+
) -> Result<(usize, Vec<String>), ReadlineError> {
115121
let components: Vec<_> = line.trim_start().split_whitespace().collect();
116122

117123
// Check whether we have entered a command and either whitespace or a partial argument.
@@ -134,9 +140,11 @@ impl Completer for CmdHelper {
134140
}
135141

136142
impl Hinter for CmdHelper {
143+
type Hint = String;
144+
137145
/// Provide a hint for what argument should be presented next.
138146
/// Returns None if no hint is available.
139-
fn hint(&self, line: &str, _pos: usize) -> Option<String> {
147+
fn hint(&self, line: &str, _pos: usize, _context: &Context<'_>) -> Option<String> {
140148
let needs_space = !line.ends_with(" ");
141149
line.trim()
142150
.parse::<Cmd>()
@@ -157,6 +165,8 @@ impl Highlighter for CmdHelper {
157165
}
158166
}
159167

168+
impl Validator for CmdHelper {}
169+
160170
/// CmdHelper can be used as an `Editor` helper for entering input commands
161171
impl Helper for CmdHelper {}
162172

@@ -169,6 +179,8 @@ pub enum ReplControl {
169179
#[cfg(test)]
170180
mod tests {
171181
use super::*;
182+
use rustyline::history::MemHistory;
183+
use rustyline::Context;
172184

173185
#[test]
174186
fn test_gen_commands_macro() {
@@ -182,21 +194,24 @@ mod tests {
182194

183195
#[test]
184196
fn test_completer() {
197+
let history = MemHistory::new();
198+
let context = Context::new(&history);
199+
185200
let cmdhelper = CmdHelper::new();
186201
assert!(cmdhelper
187-
.complete("establ", 0)
202+
.complete("establ", 0, &context)
188203
.unwrap()
189204
.1
190205
.contains(&"establish-stream".to_string()));
191-
assert!(cmdhelper.complete("he", 0).unwrap().1.contains(&"help".to_string()));
192-
assert!(cmdhelper.complete("sus", 0).unwrap().1.contains(&"suspend".to_string()));
206+
assert!(cmdhelper.complete("he", 0, &context).unwrap().1.contains(&"help".to_string()));
207+
assert!(cmdhelper.complete("sus", 0, &context).unwrap().1.contains(&"suspend".to_string()));
193208
assert!(cmdhelper
194-
.complete("suspend-", 0)
209+
.complete("suspend-", 0, &context)
195210
.unwrap()
196211
.1
197212
.contains(&"suspend-reconfigure".to_string()));
198213
assert!(cmdhelper
199-
.complete("get-a", 0)
214+
.complete("get-a", 0, &context)
200215
.unwrap()
201216
.1
202217
.contains(&"get-all-capabilities".to_string()));

src/connectivity/bluetooth/tools/bt-avdtp-tool/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ fn cmd_stream() -> (impl Stream<Item = String>, impl Sink<(), Error = SendError>
297297
.completion_type(CompletionType::List)
298298
.edit_mode(EditMode::Emacs)
299299
.build();
300-
let mut rl: Editor<CmdHelper> = Editor::with_config(config);
300+
let mut rl: Editor<CmdHelper, _> = Editor::with_config(config)?;
301301
rl.set_helper(Some(CmdHelper::new()));
302302
loop {
303303
let readline = rl.readline(PROMPT);

src/connectivity/bluetooth/tools/bt-avrcp-controller/src/commands.rs

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ use rustyline::completion::Completer;
77
use rustyline::error::ReadlineError;
88
use rustyline::highlight::Highlighter;
99
use rustyline::hint::Hinter;
10-
use rustyline::Helper;
10+
use rustyline::validate::Validator;
11+
use rustyline::{Context, Helper};
1112
use std::borrow::Cow::{self, Borrowed, Owned};
1213
use std::fmt;
1314
use std::str::FromStr;
@@ -213,7 +214,12 @@ impl CmdHelper {
213214
impl Completer for CmdHelper {
214215
type Candidate = String;
215216

216-
fn complete(&self, line: &str, _pos: usize) -> Result<(usize, Vec<String>), ReadlineError> {
217+
fn complete(
218+
&self,
219+
line: &str,
220+
_pos: usize,
221+
_context: &Context<'_>,
222+
) -> Result<(usize, Vec<String>), ReadlineError> {
217223
let components: Vec<_> = line.trim_start().split_whitespace().collect();
218224

219225
// Check whether we have entered a command and either whitespace or a partial argument.
@@ -254,8 +260,10 @@ impl Completer for CmdHelper {
254260
}
255261

256262
impl Hinter for CmdHelper {
263+
type Hint = String;
264+
257265
/// CmdHelper provides hints for commands with arguments
258-
fn hint(&self, line: &str, _pos: usize) -> Option<String> {
266+
fn hint(&self, line: &str, _pos: usize, _context: &Context<'_>) -> Option<String> {
259267
let needs_space = !line.ends_with(" ");
260268
line.trim()
261269
.parse::<Cmd>()
@@ -275,6 +283,8 @@ impl Highlighter for CmdHelper {
275283
}
276284
}
277285

286+
impl Validator for CmdHelper {}
287+
278288
/// CmdHelper can be used as an `Editor` helper for entering input commands
279289
impl Helper for CmdHelper {}
280290

@@ -287,6 +297,8 @@ pub enum ReplControl {
287297
#[cfg(test)]
288298
mod tests {
289299
use super::*;
300+
use rustyline::history::MemHistory;
301+
use rustyline::Context;
290302

291303
#[test]
292304
fn test_avc_match_string() {
@@ -304,40 +316,55 @@ mod tests {
304316

305317
#[test]
306318
fn test_completer() {
319+
let history = MemHistory::new();
320+
let context = Context::new(&history);
321+
307322
let cmdhelper = CmdHelper::new();
308-
assert!(cmdhelper.complete("ke", 0).unwrap().1.contains(&"key".to_string()));
309-
assert!(cmdhelper.complete("get", 0).unwrap().1.contains(&"get-media".to_string()));
310-
assert!(cmdhelper.complete("key ex", 0).unwrap().1.contains(&"key exit".to_string()));
323+
assert!(cmdhelper.complete("ke", 0, &context).unwrap().1.contains(&"key".to_string()));
324+
assert!(cmdhelper
325+
.complete("get", 0, &context)
326+
.unwrap()
327+
.1
328+
.contains(&"get-media".to_string()));
311329
assert!(cmdhelper
312-
.complete("conne", 0)
330+
.complete("key ex", 0, &context)
331+
.unwrap()
332+
.1
333+
.contains(&"key exit".to_string()));
334+
assert!(cmdhelper
335+
.complete("conne", 0, &context)
313336
.unwrap()
314337
.1
315338
.contains(&"connection-status".to_string()));
316339
assert!(cmdhelper
317-
.complete("send-ra", 0)
340+
.complete("send-ra", 0, &context)
318341
.unwrap()
319342
.1
320343
.contains(&"send-raw-vendor-command".to_string()));
321344
assert!(cmdhelper
322-
.complete("get-s", 0)
345+
.complete("get-s", 0, &context)
323346
.unwrap()
324347
.1
325348
.contains(&"get-supported-events".to_string()));
326349
assert!(cmdhelper
327-
.complete("get-play-", 0)
350+
.complete("get-play-", 0, &context)
328351
.unwrap()
329352
.1
330353
.contains(&"get-play-status".to_string()));
331354
assert!(cmdhelper
332-
.complete("get-playe", 0)
355+
.complete("get-playe", 0, &context)
333356
.unwrap()
334357
.1
335358
.contains(&"get-player-application-settings".to_string()));
336359
assert!(cmdhelper
337-
.complete("set", 0)
360+
.complete("set", 0, &context)
338361
.unwrap()
339362
.1
340363
.contains(&"set-player-application-settings".to_string()));
341-
assert!(cmdhelper.complete("set-v", 0).unwrap().1.contains(&"set-volume".to_string()));
364+
assert!(cmdhelper
365+
.complete("set-v", 0, &context)
366+
.unwrap()
367+
.1
368+
.contains(&"set-volume".to_string()));
342369
}
343370
}

src/connectivity/bluetooth/tools/bt-avrcp-controller/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ fn cmd_stream() -> (impl Stream<Item = String>, impl Sink<(), Error = SendError>
468468
.completion_type(CompletionType::List)
469469
.edit_mode(EditMode::Emacs)
470470
.build();
471-
let mut rl: Editor<CmdHelper> = Editor::with_config(config);
471+
let mut rl: Editor<CmdHelper, _> = Editor::with_config(config)?;
472472
rl.set_helper(Some(CmdHelper::new()));
473473
loop {
474474
let readline = rl.readline(PROMPT);

src/connectivity/bluetooth/tools/bt-bredr-profile/src/commands.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ use rustyline::completion::Completer;
66
use rustyline::error::ReadlineError;
77
use rustyline::highlight::Highlighter;
88
use rustyline::hint::Hinter;
9-
use rustyline::Helper;
9+
use rustyline::validate::Validator;
10+
use rustyline::{Context, Helper};
1011
use std::borrow::Cow::{self, Borrowed, Owned};
1112
use std::fmt;
1213
use std::str::FromStr;
@@ -136,7 +137,12 @@ impl CmdHelper {
136137
impl Completer for CmdHelper {
137138
type Candidate = String;
138139

139-
fn complete(&self, line: &str, _pos: usize) -> Result<(usize, Vec<String>), ReadlineError> {
140+
fn complete(
141+
&self,
142+
line: &str,
143+
_pos: usize,
144+
_context: &Context<'_>,
145+
) -> Result<(usize, Vec<String>), ReadlineError> {
140146
let components: Vec<_> = line.trim_start().split_whitespace().collect();
141147

142148
// Check whether we have entered a command and either whitespace or a partial argument.
@@ -159,9 +165,11 @@ impl Completer for CmdHelper {
159165
}
160166

161167
impl Hinter for CmdHelper {
168+
type Hint = String;
169+
162170
/// Provide a hint for what argument should be presented next.
163171
/// Returns None if no hint is available.
164-
fn hint(&self, line: &str, _pos: usize) -> Option<String> {
172+
fn hint(&self, line: &str, _pos: usize, _context: &Context<'_>) -> Option<String> {
165173
let needs_space = !line.ends_with(" ");
166174
line.trim()
167175
.parse::<Cmd>()
@@ -182,5 +190,7 @@ impl Highlighter for CmdHelper {
182190
}
183191
}
184192

193+
impl Validator for CmdHelper {}
194+
185195
/// CmdHelper can be used as an `Editor` helper for entering input commands
186196
impl Helper for CmdHelper {}

src/connectivity/bluetooth/tools/bt-bredr-profile/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ fn cmd_stream() -> (impl Stream<Item = String>, impl Sink<(), Error = SendError>
467467
.history_ignore_space(true)
468468
.completion_type(CompletionType::List)
469469
.build();
470-
let mut rl = Editor::<CmdHelper>::with_config(config);
470+
let mut rl = Editor::<CmdHelper, _>::with_config(config)?;
471471
rl.set_helper(Some(CmdHelper::new()));
472472

473473
loop {

src/connectivity/bluetooth/tools/bt-cli/src/commands.rs

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ use rustyline::completion::Completer;
77
use rustyline::error::ReadlineError;
88
use rustyline::highlight::Highlighter;
99
use rustyline::hint::Hinter;
10-
use rustyline::Helper;
10+
use rustyline::validate::Validator;
11+
use rustyline::{Context, Helper};
1112
use std::borrow::Cow::{self, Borrowed, Owned};
1213
use std::fmt;
1314
use std::str::FromStr;
@@ -124,7 +125,12 @@ impl Completer for CmdHelper {
124125
// TODO(belgum): complete arguments for commands. Should be generalized to use the information
125126
// given by the Cmd enum with a closure for extracting a list from state.
126127
// Complete command variants
127-
fn complete(&self, line: &str, _pos: usize) -> Result<(usize, Vec<String>), ReadlineError> {
128+
fn complete(
129+
&self,
130+
line: &str,
131+
_pos: usize,
132+
_context: &Context<'_>,
133+
) -> Result<(usize, Vec<String>), ReadlineError> {
128134
let components: Vec<_> = line.trim_start().split_whitespace().collect();
129135

130136
// Check whether we have entered a command and either whitespace or a partial argument.
@@ -169,8 +175,10 @@ impl Completer for CmdHelper {
169175
}
170176

171177
impl Hinter for CmdHelper {
178+
type Hint = String;
179+
172180
/// CmdHelper provides hints for commands with arguments
173-
fn hint(&self, line: &str, _pos: usize) -> Option<String> {
181+
fn hint(&self, line: &str, _pos: usize, _context: &Context<'_>) -> Option<String> {
174182
let needs_space = !line.ends_with(" ");
175183
line.trim()
176184
.parse::<Cmd>()
@@ -190,6 +198,8 @@ impl Highlighter for CmdHelper {
190198
}
191199
}
192200

201+
impl Validator for CmdHelper {}
202+
193203
/// CmdHelper can be used as an `Editor` helper for entering input commands
194204
impl Helper for CmdHelper {}
195205

@@ -202,6 +212,8 @@ pub enum ReplControl {
202212
#[cfg(test)]
203213
mod tests {
204214
use super::*;
215+
use rustyline::history::MemHistory;
216+
use rustyline::Context;
205217

206218
#[test]
207219
fn test_gen_commands_macro() {
@@ -212,10 +224,21 @@ mod tests {
212224

213225
#[test]
214226
fn test_completer() {
227+
let history = MemHistory::new();
228+
let context = Context::new(&history);
229+
215230
let state = Arc::new(Mutex::new(State::new()));
216231
let cmdhelper = CmdHelper::new(state);
217-
assert!(cmdhelper.complete("he", 0).unwrap().1.contains(&"help".to_string()));
218-
assert!(cmdhelper.complete("dis", 0).unwrap().1.contains(&"discoverable".to_string()));
219-
assert!(cmdhelper.complete("set-", 0).unwrap().1.contains(&"set-local-name".to_string()));
232+
assert!(cmdhelper.complete("he", 0, &context).unwrap().1.contains(&"help".to_string()));
233+
assert!(cmdhelper
234+
.complete("dis", 0, &context)
235+
.unwrap()
236+
.1
237+
.contains(&"discoverable".to_string()));
238+
assert!(cmdhelper
239+
.complete("set-", 0, &context)
240+
.unwrap()
241+
.1
242+
.contains(&"set-local-name".to_string()));
220243
}
221244
}

src/connectivity/bluetooth/tools/bt-cli/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ fn cmd_stream(
646646
.edit_mode(EditMode::Emacs)
647647
.build();
648648
let c = CmdHelper::new(state);
649-
let mut rl: Editor<CmdHelper> = Editor::with_config(config);
649+
let mut rl: Editor<CmdHelper, _> = Editor::with_config(config)?;
650650
rl.set_helper(Some(c));
651651
loop {
652652
let readline = rl.readline(PROMPT);

0 commit comments

Comments
 (0)