windows-troll 0.1.0

Modular Windows prank library
//! CLI wiring for the troll modules.
//!
//! The [`CliModule`] trait decouples a module's library API (in
//! [`windows_troll::modules`]) from its command-line surface. Each module ships
//! a per-module CLI under [`cli::modules`] and registers it in [`all`]; the
//! binary in `src/main.rs` only knows about the registry.

pub mod modules;

use clap::{ArgMatches, Command};

/// A single troll module's command-line interface.
pub trait CliModule {
    /// The subcommand name, e.g. `"window-hider"`.
    fn name(&self) -> &'static str;

    /// One-line description shown in the root help text.
    #[allow(dead_code)]
    fn about(&self) -> &'static str;

    /// The clap subcommand (with its own subcommands and args) for this module.
    fn command(&self) -> Command;

    /// Execute this module with the parsed arguments of its subcommand.
    fn run(&self, matches: &ArgMatches) -> Result<(), Box<dyn std::error::Error>>;
}

/// The full list of module CLIs, in registration order.
///
/// Register a new troll module here; its `CliModule` implementation lives in
/// [`modules`].
#[allow(clippy::vec_init_then_push, unused_mut)]
pub fn all() -> Vec<Box<dyn CliModule>> {
    let mut clis: Vec<Box<dyn CliModule>> = Vec::new();

    #[cfg(feature = "mouse-teleporter")]
    clis.push(Box::new(modules::mouse_teleporter::MouseTeleporterCli));
    #[cfg(feature = "window-hider")]
    clis.push(Box::new(modules::window_hider::WindowHiderCli));
    #[cfg(feature = "window-party")]
    clis.push(Box::new(modules::window_party::WindowPartyCli));
    #[cfg(feature = "window-wobbler")]
    clis.push(Box::new(modules::window_wobbler::WindowWobblerCli));

    clis
}