wdotool 0.1.2

xdotool-compatible automation for Wayland
use clap::{Parser, Subcommand};

#[derive(Parser, Debug)]
#[command(
    name = "wdotool",
    version,
    about = "xdotool-compatible automation for Wayland",
    disable_help_subcommand = true
)]
pub struct Cli {
    /// Force a specific backend (libei, wlroots, kde, gnome, uinput).
    #[arg(long, global = true)]
    pub backend: Option<String>,

    /// Enable debug logging.
    #[arg(short, long, global = true)]
    pub verbose: bool,

    #[command(subcommand)]
    pub command: Command,
}

#[derive(Subcommand, Debug)]
pub enum Command {
    /// Press and release a key chain (e.g. "ctrl+c").
    Key { chain: String },

    /// Press a key chain without releasing.
    Keydown { chain: String },

    /// Release a previously pressed key chain.
    Keyup { chain: String },

    /// Type a literal string.
    Type {
        /// Delay between characters in milliseconds.
        #[arg(long, default_value_t = 12)]
        delay: u64,
        text: String,
    },

    /// Move the mouse to (x, y) or by (dx, dy) with --relative.
    Mousemove {
        #[arg(long)]
        relative: bool,
        x: i32,
        y: i32,
    },

    /// Press and release a mouse button by xdotool index (1=left, 2=middle, 3=right).
    Click { button: u32 },

    /// Press a mouse button.
    Mousedown { button: u32 },

    /// Release a mouse button.
    Mouseup { button: u32 },

    /// Scroll. Positive dy scrolls down; positive dx scrolls right.
    Scroll { dx: f64, dy: f64 },

    /// List windows matching the filters. With no filter, lists all windows.
    Search {
        #[arg(long)]
        name: Option<String>,
        #[arg(long)]
        class: Option<String>,
    },

    /// Print the active window's id.
    Getactivewindow,

    /// Activate (raise + focus) a window by id.
    Windowactivate { id: String },

    /// Close a window by id.
    Windowclose { id: String },

    /// Show detected environment and backend capabilities.
    Info,
}