console_tester/
lib.rs

1//! This is documentation for the `console_tester` crate.
2//! 
3//! # What is this?
4//! The purpose of this crate is to aid developers by allowing them to test their console code on multiple  
5//! different terminals. When it comes to displaying data, not all terminals handle output in the same  
6//! manner. One might find that a particular escape sequence is properly displayed through terminal A but  
7//! the same is not the case for terminal B. Thus, the developer may be required to configure these escape  
8//! sequences differently for different environments. This can be a source of frustration for those that  
9//! desire consistent output across the board. By providing a means to compare expected and actual output  
10//! data on a selected terminal (or list of terminals), we hope to expedite the testing process.   
11//! 
12//! # How is this done?
13//! Through the `TermWriter` and `TermStrings` structs, this crate parses data given by the user and  
14//! compares it against a list of known good escape sequences for the given terminal. If one or more bad  
15//! escape sequences are found in the input data, the input data is displayed on the screen with the bad  
16//! sequences highlighted and the good sequences removed.  
17//!   
18//! + **TermWriter**  
19//! >  The TermWriter module stores user data. TermWriter also contains the *compare* function which handles  
20//! various possible errors and provides feedback to the user.
21//! <br/>
22//!   
23//! + **TermString**  
24//! >  The TermStrings module holds the valid escape sequences for a given terminal. When the user selects  
25//! the terminal they wish to test their input data against, TermSring is populated by the known good escape  
26//! sequences for that terminal.  
27//!   
28//! # How do I use this?
29//! In an effort for simplicity and clarity, the following examples will show how to use this crate. You'll  
30//! notice (Example 1) does not provide a terminal to test user input data against. In this case, TermStrings  
31//! will just default to the current terminal.
32//! <br/>
33//!   
34//! **In simple terms, what does using this crate look like?**  
35//!   
36//! Feed in the string or data you wish to test, provide an argument for the selected terminal (if desired),  
37//! results will be displayed.  
38//! 
39//! ### Example 1:  general use, no arguments
40//! ```
41//!     use console_tester::buffer::TermWriter;
42//!     use console_tester::term::TermStrings;
43//!     use std::io::Write;
44//!
45//!     let mut buffer: TermWriter = TermWriter::new();
46//!     buffer.write(b"Console output information here");
47//!
48//!     // Find local terminal
49//!     let cmd_ts: TermStrings = TermStrings::new_from_env();
50//!
51//!     let b1 = buffer.compare(cmd_ts);
52//! ```
53//!   
54//! ### Example 2:  with argument
55//! ```
56//!     use console_tester::buffer::TermWriter;
57//!     use console_tester::term::TermStrings;
58//!     use std::io::Write;
59//!
60//!     let mut buffer: TermWriter = TermWriter::new();
61//!     buffer.write(b"Console output information here");
62//!
63//!     // x-term test
64//!     let path = std::path::Path::new("./terminfo_files/x/xterm");
65//!     let cmd_ts: TermStrings = TermStrings::new_from_path(path);
66//!
67//!     let b1 = buffer.compare(cmd_ts);
68//! ```
69//! 
70//! ### Example 3:  with multiple arguments
71//! ```
72//!     use console_tester::buffer::TermWriter;
73//!     use console_tester::term::TermStrings;
74//!     use std::io::Write;
75//!
76//!     let mut buffer: TermWriter = TermWriter::new();
77//!     buffer.write(b"Console output information here");
78//!
79//!     // clone existing buffer
80//!     let buffer2: TermWriter = buffer.clone();
81//!
82//!     // x-term test
83//!     let path = std::path::Path::new("./terminfo_files/x/xterm");
84//!     let cmd_ts: TermStrings = TermStrings::new_from_path(path);
85//!
86//!     // cygwin test
87//!     let path2 = std::path::Path::new("./terminfo_files/c/cygwin");
88//!     let cmd_cygwin: TermStrings = TermStrings::new_from_path(path);
89//!
90//!     let b1 = buffer.compare(cmd_ts);
91//!     let b2 = buffer2.compare(cmd_cygwin);
92//! ```
93//! 
94//! ### Example 4:  bad escape sequence found
95//! ```
96//!     use console_tester::buffer::TermWriter;
97//!     use console_tester::term::TermStrings;
98//!     use std::io::Write;
99//!
100//!     let mut buffer: TermWriter = TermWriter::new();
101//!     buffer.write(b"Console output information here");
102//!
103//!     // x-term test
104//!     let path = std::path::Path::new("./terminfo_files/x/xterm");
105//!     let cmd_ts: TermStrings = TermStrings::new_from_path(path);
106//!
107//!     let b1 = buffer.compare(cmd_ts);
108//! ```
109
110#![crate_type = "lib"]
111#![crate_name = "console_tester"]
112
113// Internal Exposure
114mod reg;
115
116// Public Exposure
117pub mod buffer;
118pub mod term;