consolex 0.1.0

Windows console utilities: probe, create, and release the console of the current process, plus a small CLI.
//! 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.

#![warn(missing_docs)]
#![forbid(unsafe_op_in_unsafe_fn)]

pub mod console;
pub mod error;

pub use console::{
    attach, detach, has_console, init, set_mode, show, wait_key, Attached, Mode,
};
pub use error::{Error, Result};