#![deny(clippy::all)]
#![deny(unsafe_code)]
#![allow(unused_imports)]

//! Keep library for managing temporary files with compression and metadata.
//!
//! This library provides core functionality for the Keep application, including
//! database operations, compression engines, item services, and plugin systems
//! for metadata and filtering. It supports CLI modes, server APIs, and plugin
//! registration via ctors.
//!
//! # Usage
//!
//! Add to Cargo.toml and use re-exported types:
//! ```toml
//! [dependencies]
//! keep = "0.1"
//! ```
//!
//! ```rust
//! # use keep::Args;
//! # use clap::Parser;
//! let args = Args::parse();
//! ```
//!
//! # Features
//!
//! - `server`: Enables Axum-based HTTP server.
//! - `gzip`, `lz4`: Built-in compression support.
//! - `magic`: File type detection via libmagic.

// Re-export modules for testing
pub mod args;
pub mod common;
pub mod compression_engine;
pub mod config;
pub mod db;
pub mod filter_plugin;
pub mod meta_plugin;
pub mod modes;
pub mod services;

#[cfg(feature = "client")]
pub mod client;

#[cfg(feature = "tokens")]
pub mod tokenizer;

// Re-export Args struct for library usage
pub use args::Args;
// Re-export PIPESIZE constant
pub use common::PIPESIZE;

// Import all filter plugins to ensure they register themselves
#[allow(unused_imports)]
use filter_plugin::{grep, head, skip, strip_ansi, tail};

#[cfg(feature = "tokens")]
#[allow(unused_imports)]
use filter_plugin::tokens as token_filters;

use crate::meta_plugin::{
    cwd, digest, env, exec, hostname, keep_pid, read_rate, read_time, shell, shell_pid, user,
};

#[cfg(feature = "magic")]
#[allow(unused_imports)]
use crate::meta_plugin::magic_file;

#[cfg(feature = "tokens")]
#[allow(unused_imports)]
use crate::meta_plugin::tokens;

#[cfg(feature = "infer")]
#[allow(unused_imports)]
use crate::meta_plugin::infer_plugin;

#[cfg(feature = "tree_magic_mini")]
#[allow(unused_imports)]
use crate::meta_plugin::tree_magic_mini;

/// Initializes plugins at library load time.
///
/// Plugin registration happens automatically via `#[ctor]` constructors
/// when each plugin module is loaded. The explicit module imports in
/// `lib.rs` guarantee this happens at library initialization time.
///
/// This function exists as a public API entry point for callers that
/// want to explicitly ensure plugins are ready. It intentionally does
/// no additional work.
///
/// # Examples
///
/// ```
/// keep::init_plugins();
/// ```
pub fn init_plugins() {
    // Plugins self-register via #[ctor] on module load.
    // The use-statements in lib.rs guarantee module inclusion.
}

#[cfg(test)]
mod tests;
