Skip to main content

lineread/
lib.rs

1//! Provides a configurable, concurrent, extensible, interactive input reader
2//! for Unix terminals and Windows console.
3//!
4//! Configuration is compatible with GNU Readline.
5//!
6//! The main entry to interactive read operations is the [`Interface`] type.
7//!
8//! # Basic example
9//!
10//! ```no_run
11//! # use std::io;
12//! use lineread::{Interface, ReadResult};
13//!
14//! # fn run() -> io::Result<()> {
15//! let mut reader = Interface::new("my-application")?;
16//!
17//! reader.set_prompt("my-app> ")?;
18//!
19//! while let ReadResult::Input(input) = reader.read_line()? {
20//!     println!("got input {:?}", input);
21//! }
22//!
23//! println!("Goodbye.");
24//! # Ok(())
25//! # }
26//! ```
27//!
28//! [`Interface`]: interface/struct.Interface.html
29
30#![deny(missing_docs)]
31
32#[cfg(test)]
33#[macro_use]
34extern crate assert_matches;
35
36pub use crate::command::Command;
37pub use crate::complete::{Completer, Completion, Suffix};
38pub use crate::function::Function;
39pub use crate::interface::Interface;
40pub use crate::prompter::Prompter;
41pub use crate::reader::{ReadResult, Reader};
42pub use crate::terminal::{DefaultTerminal, Signal, Terminal};
43pub use crate::writer::Writer;
44
45pub mod chars;
46pub mod command;
47pub mod complete;
48pub mod function;
49pub mod highlighting;
50pub mod inputrc;
51pub mod interface;
52pub mod memory;
53pub mod prompter;
54pub mod reader;
55pub mod table;
56pub mod terminal;
57pub mod util;
58pub mod variables;
59pub mod writer;
60
61#[cfg(unix)]
62#[path = "unix/mod.rs"]
63mod sys;
64
65#[cfg(windows)]
66#[path = "windows/mod.rs"]
67mod sys;
68
69#[cfg(test)]
70mod test {
71    use crate::interface::Interface;
72    use crate::terminal::{DefaultTerminal, Terminal};
73
74    fn assert_has_traits<T: 'static + Send + Sync>() {}
75
76    fn assert_generic_traits<T: 'static + Terminal>() {
77        assert_has_traits::<Interface<T>>();
78    }
79
80    #[test]
81    fn test_interface_traits() {
82        assert_generic_traits::<DefaultTerminal>();
83    }
84}