linefeed/
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 linefeed::{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)] #[macro_use] extern crate assert_matches;
33
34pub use crate::command::Command;
35pub use crate::complete::{Completer, Completion, Suffix};
36pub use crate::function::Function;
37pub use crate::interface::Interface;
38pub use crate::prompter::Prompter;
39pub use crate::reader::{Reader, ReadResult};
40pub use crate::terminal::{DefaultTerminal, Signal, Terminal};
41pub use crate::writer::Writer;
42
43pub mod chars;
44pub mod command;
45pub mod complete;
46pub mod function;
47pub mod inputrc;
48pub mod interface;
49pub mod memory;
50pub mod prompter;
51pub mod reader;
52pub mod table;
53pub mod terminal;
54mod util;
55pub mod variables;
56pub mod writer;
57
58#[cfg(unix)]
59#[path = "unix/mod.rs"]
60mod sys;
61
62#[cfg(windows)]
63#[path = "windows/mod.rs"]
64mod sys;
65
66#[cfg(test)]
67mod test {
68    use crate::interface::Interface;
69    use crate::terminal::{DefaultTerminal, Terminal};
70
71    fn assert_has_traits<T: 'static + Send + Sync>() {}
72
73    fn assert_generic_traits<T: 'static + Terminal>() {
74        assert_has_traits::<Interface<T>>();
75    }
76
77    #[test]
78    fn test_interface_traits() {
79        assert_generic_traits::<DefaultTerminal>();
80    }
81}