#![deny(missing_docs)]
#![deny(clippy::missing_docs_in_private_items)]
// SPDX-FileCopyrightText: Peter Pentchev <roam@ringlet.net>
// SPDX-License-Identifier: BSD-2-Clause
//! Random collection of helper libraries used by Ringlet software.
//!
//! The [`cli_basic`] module provides helper functions for command-line parsing,
//! more specifically handling the `--help`, `--version`, and `--features` options in
//! a Ringlet-specific way.
//!
//! The [`test_exe`] module provides a "find the executable" helper for test suites.
//!
//! The [`test_log`] module provides a logging helper for test suites.

#![doc(html_root_url = "https://docs.rs/roundlet/0.1.4")]

use core::iter;

#[cfg(feature = "cli-basic-clap")]
pub mod cli_basic;

#[cfg(feature = "env-utf8")]
pub mod env;

#[cfg(feature = "test-log-simple")]
pub mod test_log;

#[cfg(feature = "test-exe-path")]
pub mod test_exe;

/// Get the list of features supported by the library.
#[inline]
pub fn features() -> impl Iterator<Item = (&'static str, &'static str)> {
    let it_base = iter::once(("roundlet", env!("CARGO_PKG_VERSION")));

    #[cfg(not(feature = "cli-basic-clap"))]
    let it_cli_basic = it_base;
    #[cfg(feature = "cli-basic-clap")]
    let it_cli_basic = it_base.chain(cli_basic::features());

    #[cfg(not(feature = "env-utf8"))]
    let it_env = it_cli_basic;
    #[cfg(feature = "env-utf8")]
    let it_env = it_cli_basic.chain(env::features());

    #[cfg(not(feature = "test-exe-path"))]
    let it_test_exe = it_env;
    #[cfg(feature = "test-exe-path")]
    let it_test_exe = it_env.chain(test_exe::features());

    #[cfg(not(feature = "test-log-simple"))]
    let it_test_log = it_test_exe;
    #[cfg(feature = "test-log-simple")]
    let it_test_log = it_test_exe.chain(test_log::features());

    it_test_log
}
