Skip to main content

ndpm/
args.rs

1use clap::{Args, Parser, Subcommand};
2
3/// A user-friendly package manager wrapper for XBPS with AppImage support
4#[derive(Debug, Parser)]
5#[command(version, about, long_about = None)]
6pub struct Cli {
7    #[command(subcommand)]
8    pub command: Command,
9}
10
11#[derive(Debug, Subcommand)]
12pub enum Command {
13    /// Install one or more packages
14    #[command(name = "install")]
15    Install(InstallArgs),
16
17    /// Update package database
18    #[command(name = "update")]
19    Update,
20
21    /// Upgrade installed packages
22    #[command(name = "upgrade")]
23    Upgrade(UpgradeArgs),
24
25    /// Remove one or more packages
26    #[command(name = "remove")]
27    Remove(RemoveArgs),
28
29    /// Search for packages in repositories
30    #[command(name = "search")]
31    Search(SearchArgs),
32
33    /// Manage AppImages (alias: a, ai)
34    #[command(name = "appimage", aliases = ["a", "ai"])]
35    AppImage {
36        #[command(subcommand)]
37        action: zap_rs::Command,
38    },
39
40    /// Enable the Noid's custom repository
41    #[command(name = "repo")]
42    Repo,
43}
44
45#[derive(Debug, Args)]
46pub struct InstallArgs {
47    /// Package names to install
48    pub packages: Vec<String>,
49
50    /// Assume yes for all prompts
51    #[arg(long, short = 'y', default_value_t = false)]
52    pub yes: bool,
53}
54
55#[derive(Debug, Args)]
56pub struct UpgradeArgs {
57    /// Specific packages to upgrade (all if empty)
58    pub packages: Vec<String>,
59
60    /// Assume yes for all prompts
61    #[arg(long, short = 'y', default_value_t = false)]
62    pub yes: bool,
63}
64
65#[derive(Debug, Args)]
66pub struct RemoveArgs {
67    /// Package names to remove
68    pub packages: Vec<String>,
69
70    /// Assume yes for all prompts
71    #[arg(long, short = 'y', default_value_t = false)]
72    pub yes: bool,
73}
74
75#[derive(Debug, Args)]
76pub struct SearchArgs {
77    /// Package name or pattern to search for
78    pub package: String,
79}