df3 0.1.2

Advanced disk free utility - modern alternative to df command
Documentation
// File: src\cli.rs
// Author: Hadi Cahyadi <cumulus13@gmail.com>
// Date: 2026-06-16
// Description:
// License: MIT

use clap::{Parser, ValueEnum};

#[derive(Parser, Debug)]
#[command(
    name = "df",
    version,
    about = "Advanced disk free utility - modern alternative to df command",
    long_about = "A modern, fast, and feature-rich disk usage viewer with multiple output formats and real-time monitoring capabilities.",
    author = "Hadi Cahyadi <cumulus13@gmail.com>",
    after_help = "Examples:\n  df\n  df -H\n  df /home\n  df --output json\n  df --watch 5\n  df -H -t ext4\n  df --sort percent -r\n\nConfig file locations:\n  Windows: %APPDATA%\\df3\\config.toml\n  Linux/macOS: ~/.config/df3/config.toml",
    display_order = 1
)]
pub struct Cli {
    /// Show human readable sizes (e.g., 1K 234M 2G)
    #[arg(short = 'H', long, default_value_t = true)]
    pub human_readable: bool,

    /// Limit listing to local file systems
    #[arg(short = 'l', long)]
    pub local_only: bool,

    /// Include dummy file systems
    #[arg(short = 'a', long)]
    pub all: bool,

    /// Show inode information instead of block usage
    #[arg(short = 'i', long)]
    pub inodes: bool,

    /// Output format
    #[arg(short = 'o', long, value_enum, default_value_t = OutputFormat::Table)]
    pub output: OutputFormat,

    /// Block size (e.g., 1024, 4096)
    #[arg(short = 'B', long, default_value_t = 1024)]
    pub block_size: u64,

    /// Filesystem type to show (can be specified multiple times)
    #[arg(short = 't', long = "type")]
    pub fs_type: Vec<String>,

    /// Filesystem type to exclude (can be specified multiple times)
    #[arg(short = 'x', long = "exclude-type")]
    pub exclude_type: Vec<String>,

    /// Sort by field: size, used, avail, percent, mount
    #[arg(short = 'S', long, value_enum)]
    pub sort: Option<SortField>,

    /// Reverse sort order
    #[arg(short = 'r', long)]
    pub reverse: bool,

    /// Total row at the end
    #[arg(long)]
    pub total: bool,

    /// Display sync progress
    #[arg(short = 's', long)]
    pub sync: bool,

    /// Watch mode - refresh every N seconds
    #[arg(short = 'w', long, default_value_t = 0)]
    pub watch: u64,

    /// Use custom config file
    #[arg(short = 'c', long)]
    pub config: Option<String>,

    /// Show version information
    #[arg(short = 'V', long)]
    pub version: bool,

    /// Mount point(s) to show
    #[arg()]
    pub mounts: Vec<String>,
}

#[derive(ValueEnum, Clone, Debug, PartialEq)]
pub enum OutputFormat {
    /// Standard table output
    Table,
    /// JSON output
    Json,
    /// CSV output
    Csv,
    /// Inode information
    Inodes,
}

#[derive(ValueEnum, Clone, Debug, PartialEq)]
pub enum SortField {
    /// Sort by filesystem name
    Filesystem,
    /// Sort by total size
    Size,
    /// Sort by used space
    Used,
    /// Sort by available space
    Avail,
    /// Sort by use percentage
    Percent,
    /// Sort by mount point
    Mounted,
}

pub fn parse() -> Cli {
    Cli::parse()
}