nixy-rs 0.5.0

Homebrew-style wrapper for Nix using flake.nix
use clap::{Args, Parser, Subcommand};

#[derive(Parser)]
#[command(
    name = "nixy",
    about = "Homebrew-style wrapper for Nix using flake.nix",
    disable_help_subcommand = true
)]
#[command(version)]
pub struct Cli {
    #[command(subcommand)]
    pub command: Commands,
}

#[derive(Subcommand)]
pub enum Commands {
    /// Install a package from nixpkgs [alias: add]
    #[command(alias = "add")]
    Install(InstallArgs),

    /// Uninstall a package [alias: remove]
    #[command(alias = "remove")]
    Uninstall(UninstallArgs),

    /// List packages in flake.nix [alias: ls]
    #[command(alias = "ls")]
    List,

    /// Search for packages
    Search {
        /// Search query
        query: String,
    },

    /// Update packages and flake inputs
    Update(UpdateArgs),

    /// Build environment from flake.nix and create symlink
    Sync(SyncArgs),

    /// Output shell config (for eval in rc files)
    Config {
        /// Shell type (bash, zsh, fish)
        shell: String,
    },

    /// Profile management commands
    Profile(ProfileArgs),

    /// Upgrade nixy to the latest version
    Upgrade(UpgradeArgs),

    /// Show path to package source file in Nix store
    File(FileArgs),

    /// Print dynamic completion candidates (used by shell completions)
    #[command(hide = true)]
    Completions(CompletionsArgs),
}

#[derive(Args)]
pub struct InstallArgs {
    /// Package name to install
    pub package: Option<String>,

    /// Only install on specific platform(s). Valid values: darwin, macos, linux,
    /// x86_64-darwin, aarch64-darwin, x86_64-linux, aarch64-linux
    #[arg(long, short = 'p')]
    pub platform: Vec<String>,
}

#[derive(Args)]
pub struct UpdateArgs {
    /// Specific packages or inputs to update
    pub inputs: Vec<String>,

    /// Update all packages and inputs
    #[arg(long, conflicts_with = "inputs")]
    pub all: bool,
}

#[derive(Args)]
pub struct SyncArgs {}

#[derive(Args)]
pub struct UninstallArgs {
    /// Package name to uninstall
    pub package: String,
}

#[derive(Args)]
pub struct ProfileArgs {
    /// Profile name
    pub name: Option<String>,

    /// Create the profile if it doesn't exist
    #[arg(short, conflicts_with = "d")]
    pub c: bool,

    /// Delete the specified profile
    #[arg(short, conflicts_with = "c")]
    pub d: bool,
}

#[derive(Args)]
pub struct UpgradeArgs {
    /// Force reinstall even if already at latest version
    #[arg(long, short)]
    pub force: bool,
}

#[derive(Args)]
pub struct FileArgs {
    /// Package name
    pub package: String,
}

#[derive(Args)]
pub struct CompletionsArgs {
    /// What to complete (e.g. installed, profiles)
    pub kind: String,
}