rusty-pv 0.1.0

Pipe viewer — a Rust port of Andrew Wood's `pv(1)` with progress bar, ETA, rate display, token-bucket rate limiting, IEC/SI unit math, SIGWINCH-aware terminal redraw, SIGUSR1 size refresh, multi-instance cursor coordination, and a typed library API.
Documentation
//! Default-mode CLI (clap-derive) (FR-035..FR-037).

use clap::{Parser, Subcommand};

/// Pipe viewer. A Rust port of Andrew Wood's `pv(1)`.
#[derive(Parser, Debug)]
#[command(name = "rusty-pv", about, version, arg_required_else_help = false)]
pub struct Cli {
    /// Show progress bar.
    #[arg(short = 'p', long = "progress")]
    pub progress: bool,

    /// Show elapsed time.
    #[arg(short = 't', long = "timer")]
    pub timer: bool,

    /// Show ETA based on current rate.
    #[arg(short = 'e', long = "eta")]
    pub eta: bool,

    /// Show ETA as wall-clock arrival time.
    #[arg(short = 'I', long = "fineta")]
    pub fineta: bool,

    /// Show instantaneous rate.
    #[arg(short = 'r', long = "rate")]
    pub rate: bool,

    /// Show bytes transferred.
    #[arg(short = 'b', long = "bytes")]
    pub bytes: bool,

    /// Show average rate since start.
    #[arg(short = 'a', long = "average-rate")]
    pub average_rate: bool,

    /// Numeric percentage mode (one integer per line, suitable for `dialog --gauge`).
    #[arg(short = 'n', long = "numeric")]
    pub numeric: bool,

    /// Quiet — suppress all display output.
    #[arg(short = 'q', long = "quiet")]
    pub quiet: bool,

    /// Wait until first byte transferred before showing display.
    #[arg(short = 'W', long = "wait")]
    pub wait: bool,

    /// Count newline-terminated records instead of bytes.
    #[arg(short = 'l', long = "line-mode")]
    pub line_mode: bool,

    /// Count NUL-terminated records instead of bytes.
    #[arg(short = '0', long = "null-mode")]
    pub null_mode: bool,

    /// Force display even when stderr is not a terminal.
    #[arg(short = 'f', long = "force")]
    pub force: bool,

    /// Skip read errors and continue (zero-fill).
    #[arg(short = 'E', long = "skip-errors")]
    pub skip_errors: bool,

    /// Cursor positioning mode for multi-instance pipelines (Unix only).
    #[arg(short = 'c', long = "cursor")]
    pub cursor: bool,

    /// Use SI decimal unit prefixes (kB=1000) instead of IEC binary (KiB=1024).
    #[arg(long = "si")]
    pub si_units: bool,

    /// Delay display by SEC seconds.
    #[arg(short = 'D', long = "delay-start", value_name = "SEC")]
    pub delay_start: Option<f64>,

    /// Display update interval in seconds (default 1.0).
    #[arg(short = 'i', long = "interval", value_name = "SEC")]
    pub interval: Option<f64>,

    /// Prefix the display line with NAME.
    #[arg(short = 'N', long = "name", value_name = "NAME")]
    pub name: Option<String>,

    /// Limit transfer rate (suffix-aware: 1M = 1 MiB/s by default).
    #[arg(short = 'L', long = "rate-limit", value_name = "RATE")]
    pub rate_limit: Option<String>,

    /// Internal copy-loop buffer size.
    #[arg(short = 'B', long = "buffer-size", value_name = "BYTES")]
    pub buffer_size: Option<String>,

    /// Expected total bytes (for percent / ETA).
    #[arg(short = 's', long = "size", value_name = "SIZE")]
    pub size: Option<String>,

    /// Force display width (override terminal-detected width).
    #[arg(short = 'w', long = "width", value_name = "WIDTH")]
    pub width: Option<u16>,

    /// Force display height.
    #[arg(short = 'H', long = "height", value_name = "HEIGHT")]
    pub height: Option<u16>,

    /// Activate Strict-compat mode.
    #[arg(long = "strict")]
    pub strict: bool,

    /// Disable Strict-compat mode even when argv[0] or env would activate it.
    #[arg(long = "no-strict", conflicts_with = "strict")]
    pub no_strict: bool,

    /// Optional subcommand.
    #[command(subcommand)]
    pub subcommand: Option<PvSubcommand>,

    /// Input paths (zero or more; zero implies read from stdin).
    pub paths: Vec<String>,
}

/// Subcommands exposed in Default mode only (FR-036/FR-041).
#[derive(Subcommand, Debug)]
pub enum PvSubcommand {
    /// Emit a shell-completion script to stdout.
    Completions {
        /// Target shell.
        #[arg(value_enum)]
        shell: clap_complete::Shell,
    },
}