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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//! Provides a configurable, concurrent, extensible, interactive input reader
//! for Unix terminals and Windows console.
//!
//! Configuration is compatible with GNU Readline.
//!
//! The main entry to interactive read operations is the [`Interface`] type.
//!
//! # Basic example
//!
//! ```no_run
//! # use std::io;
//! use linefeed::{Interface, ReadResult};
//!
//! # fn run() -> io::Result<()> {
//! let mut reader = Interface::new("my-application")?;
//!
//! reader.set_prompt("my-app> ")?;
//!
//! while let ReadResult::Input(input) = reader.read_line()? {
//!     println!("got input {:?}", input);
//! }
//!
//! println!("Goodbye.");
//! # Ok(())
//! # }
//! ```
//!
//! [`Interface`]: interface/struct.Interface.html

#![deny(missing_docs)]

#[cfg(test)] #[macro_use] extern crate assert_matches;

pub use crate::command::Command;
pub use crate::complete::{Completer, Completion, Suffix};
pub use crate::function::Function;
pub use crate::interface::Interface;
pub use crate::prompter::Prompter;
pub use crate::reader::{Reader, ReadResult};
pub use crate::terminal::{DefaultTerminal, Signal, Terminal};
pub use crate::writer::Writer;

pub mod chars;
pub mod command;
pub mod complete;
pub mod function;
pub mod inputrc;
pub mod interface;
pub mod memory;
pub mod prompter;
pub mod reader;
pub mod table;
pub mod terminal;
mod util;
pub mod variables;
pub mod writer;

#[cfg(unix)]
#[path = "unix/mod.rs"]
mod sys;

#[cfg(windows)]
#[path = "windows/mod.rs"]
mod sys;

#[cfg(test)]
mod test {
    use crate::interface::Interface;
    use crate::terminal::{DefaultTerminal, Terminal};

    fn assert_has_traits<T: 'static + Send + Sync>() {}

    fn assert_generic_traits<T: 'static + Terminal>() {
        assert_has_traits::<Interface<T>>();
    }

    #[test]
    fn test_interface_traits() {
        assert_generic_traits::<DefaultTerminal>();
    }
}