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
//! Windows console utilities.
//!
//! A small, focused API for probing and controlling the console attached to
//! the current process. This crate is Windows-only.
//!
//! Core API:
//!
//! - [`Mode`] — the desired console policy (`auto`, `show`, `hide`, `keep`).
//! - [`init`] — apply a [`Mode`]; returns `true` when a new console window
//! was created.
//! - [`wait_key`] — block until a key is pressed (to keep a new window
//! open).
//! - [`has_console`] — is a console attached?
//! - [`set_mode`] — apply a [`Mode`] to the process.
//!
//! Lower-level primitives: [`attach`], [`show`], [`detach`].
//!
//! # Example
//!
//! ```no_run
//! use consolex::{init, wait_key, Mode};
//!
//! // Resolve the console policy (e.g. from command-line flags via the
//! // [`Mode`] `FromIterator` impl), then apply it.
//! let mode: Mode = std::env::args_os().skip(1).collect();
//! let created = init(mode)?;
//!
//! println!("hello from a console-aware program");
//!
//! // Keep a newly created window open long enough to read the output.
//! if created {
//! wait_key()?;
//! }
//! # Ok::<(), consolex::Error>(())
//! ```
//!
//! # Building an executable
//!
//! To prevent a console window from flashing when the binary is launched by
//! a third-party program, build it as a GUI-subsystem executable:
//!
//! ```rust
//! #![cfg_attr(windows, windows_subsystem = "windows")]
//! ```
//!
//! The binary can then call [`init`] on demand instead of always getting a
//! console.
pub use ;
pub use ;