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
//! End-to-end runs.
//!
//! This module combines the [`crate::md_elem`], [`crate::select`], and [`crate::output`] mods into a single workflow.
//! It's useful for building functionality like the CLI's, but running it within-process.
//!
//! ## Example
//!
//! ```
//! # use mdq::run;
//!
//! // First, let's define a mocked I/O. Replace this with whatever you need.
//! #[derive(Default)]
//! struct MockIo {
//! stdout: Vec<u8>,
//! }
//!
//! impl run::OsFacade for MockIo {
//! fn read_stdin(&self) -> std::io::Result<String> {
//! Ok("- hello\n- world".to_string())
//! }
//!
//! fn read_file(&self, path: &str) -> std::io::Result<String> {
//! Err(std::io::Error::new(std::io::ErrorKind::NotFound, path))
//! }
//!
//! fn stdout(&mut self) -> impl std::io::Write {
//! &mut self.stdout
//! }
//!
//! fn write_error(&mut self, err: run::Error) {
//! eprintln!("{err}")
//! }
//! }
//!
//! // Now, use it:
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//!
//! // Define our "CLI" options. Use the defaults, but add a positional arg for an "- h" selector.
//! let mut cli_options = run::RunOptions::default();
//! cli_options.selectors = "- h".to_string(); // list items containing an 'h'
//!
//! let mut os_facade = MockIo::default();
//! let found_any = run::run(&cli_options, &mut os_facade);
//! let stdout_text = String::from_utf8(os_facade.stdout)?;
//!
//! assert_eq!(found_any, true);
//! assert_eq!(stdout_text, "- hello\n");
//! #
//! # Ok(())
//! # }
//! ```
pub use *;
pub use *;