1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
use clap::{Parser, Subcommand};
#[derive(Parser, Debug)]
#[command(name = "rustpm", about = "A fast, friendly APT frontend with kernel management")]
pub struct Cli {
#[command(subcommand)]
pub command: Option<Commands>,
/// Disable TUI and use plain text output
#[arg(long, global = true, env = "RUSTPM_NO_TUI")]
pub no_tui: bool,
/// Disable self-update check
#[arg(long, global = true, env = "RUSTPM_NO_UPDATE_CHECK")]
pub no_update_check: bool,
/// Enable verbose logging
#[arg(short, long, global = true)]
pub verbose: bool,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
/// Fetch updated package lists
Update,
/// Upgrade installed packages
Upgrade {
/// Perform a full-upgrade (may remove packages)
#[arg(long)]
full: bool,
},
/// Install one or more packages
Install {
packages: Vec<String>,
},
/// Remove one or more packages
Remove {
packages: Vec<String>,
/// Also remove configuration files
#[arg(long)]
purge: bool,
},
/// Remove packages and their configuration files
Purge {
packages: Vec<String>,
},
/// Search for packages
Search {
term: String,
/// Match package names only (not descriptions)
#[arg(long)]
names_only: bool,
},
/// Show details for a package
Show {
package: String,
},
/// List packages
List {
/// Only show installed packages
#[arg(long)]
installed: bool,
/// Only show upgradable packages
#[arg(long)]
upgradable: bool,
},
/// View and manage transaction history
History {
#[command(subcommand)]
action: Option<HistoryCommands>,
/// Maximum number of entries to show
#[arg(long, default_value = "20")]
limit: usize,
},
/// Manage Linux kernels
Kernel {
#[command(subcommand)]
action: KernelCommands,
},
/// Manage desktop environments
Desktop {
#[command(subcommand)]
action: DesktopCommands,
},
/// Manage APT sources
Sources {
#[command(subcommand)]
action: SourcesCommands,
},
}
#[derive(Subcommand, Debug)]
pub enum HistoryCommands {
/// Undo a transaction by ID
Undo { id: u64 },
}
#[derive(Subcommand, Debug)]
pub enum KernelCommands {
/// List installed and available kernels
List,
/// Install a Debian kernel by version
Install { version: String },
/// Remove a Debian kernel by version
Remove { version: String },
/// Upgrade to the latest available Debian kernel
Update,
/// Pin (hold) a kernel at its current version
Pin { version: String },
/// Unpin (unhold) a kernel
Unpin { version: String },
/// Manage vanilla (mainline) kernels from kernel.org
Vanilla {
#[command(subcommand)]
action: VanillaCommands,
},
}
#[derive(Subcommand, Debug)]
pub enum VanillaCommands {
/// List available vanilla kernel releases
List {
/// Show only stable releases
#[arg(long)]
stable: bool,
/// Show only mainline (rc) releases
#[arg(long)]
mainline: bool,
/// Show only longterm releases
#[arg(long)]
longterm: bool,
},
/// Download and install a vanilla kernel
Install { version: String },
/// Remove a vanilla kernel
Remove { version: String },
/// Show details for a vanilla kernel release
Info { version: String },
}
#[derive(Subcommand, Debug)]
pub enum DesktopCommands {
/// List available desktop environments
List,
/// Install a desktop environment
Install { name: String },
/// Remove a desktop environment
Remove { name: String },
/// Switch default display manager to a desktop environment's DM
Switch { name: String },
}
#[derive(Subcommand, Debug)]
pub enum SourcesCommands {
/// List configured APT sources
List,
/// Add a new APT source
Add {
uri: String,
suite: String,
components: Vec<String>,
},
/// Remove an APT source by URI
Remove { uri: String },
/// Enable a disabled APT source
Enable { uri: String },
/// Disable (comment out) an APT source
Disable { uri: String },
/// Open sources.list in $EDITOR
Edit,
}