soar-cli 0.12.1

A modern package manager for Linux
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
use clap::{ArgAction, Parser, Subcommand, ValueHint};

use crate::utils::parse_default_repos_arg;

#[derive(Parser)]
#[command(
    author,
    version,
    about,
    help_template = "{before-help}{name} {version}
{author-with-newline}{about-with-newline}
{usage-heading} {usage}

{all-args}{after-help}",
    arg_required_else_help = true
)]
pub struct Args {
    /// Set output verbosity
    #[arg(short = 'v', long, action = ArgAction::Count, global = true)]
    pub verbose: u8,

    /// Suppress outputs
    #[arg(short, long, global = true)]
    pub quiet: bool,

    /// Output as json
    #[arg(short, long, global = true)]
    pub json: bool,

    /// Disable colors in output
    #[arg(long, global = true)]
    pub no_color: bool,

    /// Disable progress bar
    #[arg(long, global = true)]
    pub no_progress: bool,

    /// Set current profile
    #[arg(short, long, global = true)]
    pub profile: Option<String>,

    /// Provide custom config file
    #[arg(short, long, global = true)]
    pub config: Option<String>,

    /// Set proxy
    #[arg(required = false, long, short = 'P', global = true)]
    pub proxy: Option<String>,

    /// Set request headers
    #[arg(required = false, long, short = 'H', global = true)]
    pub header: Option<Vec<String>>,

    /// Set user agent
    #[arg(required = false, long, short = 'A', global = true)]
    pub user_agent: Option<String>,

    /// Manage system-wide packages (requires root)
    #[arg(long, short = 'S', global = true)]
    pub system: bool,

    #[clap(subcommand)]
    pub command: Commands,
}

#[derive(Subcommand)]
pub enum RepoAction {
    /// Add a new repository
    Add {
        /// Repository name
        name: String,
        /// Repository metadata URL
        url: String,
        /// Base64-encoded public key for signature verification
        #[arg(long)]
        pubkey: Option<String>,
        /// Whether the repository is enabled
        #[arg(long)]
        enabled: Option<bool>,
        /// Enable desktop integration
        #[arg(long)]
        desktop_integration: Option<bool>,
        /// Enable signature verification
        #[arg(long)]
        signature_verification: Option<bool>,
        /// Sync interval (e.g., "1h", "12h", "1d")
        #[arg(long)]
        sync_interval: Option<String>,
    },
    /// Update an existing repository
    Update {
        /// Repository name
        name: String,
        /// Repository metadata URL
        #[arg(long)]
        url: Option<String>,
        /// Base64-encoded public key for signature verification
        #[arg(long)]
        pubkey: Option<String>,
        /// Whether the repository is enabled
        #[arg(long)]
        enabled: Option<bool>,
        /// Enable desktop integration
        #[arg(long)]
        desktop_integration: Option<bool>,
        /// Enable signature verification
        #[arg(long)]
        signature_verification: Option<bool>,
        /// Sync interval (e.g., "1h", "12h", "1d")
        #[arg(long)]
        sync_interval: Option<String>,
    },
    /// Remove a repository
    #[clap(visible_alias = "del")]
    Remove {
        /// Repository name
        name: String,
    },
    /// List configured repositories
    #[clap(visible_alias = "ls")]
    List,
}

#[derive(Subcommand)]
pub enum SelfAction {
    /// Update soar
    Update {
        /// Skip confirmation prompt
        #[arg(long, short = 'y')]
        yes: bool,
    },
    /// Uninstall soar
    Uninstall,
}

#[derive(Subcommand)]
pub enum Commands {
    /// Print the configuration file to stdout
    Config {
        /// Open the configuration file in editor
        /// Optional value can be passed to set as editor (default is $EDITOR)
        #[arg(required = false, short, long)]
        edit: Option<Option<String>>,
    },

    /// Install packages
    #[command(arg_required_else_help = true)]
    #[clap(name = "install", visible_alias = "i", visible_alias = "add")]
    Install {
        /// Packages to install
        #[arg(required = true)]
        packages: Vec<String>,

        /// Whether to force install the package
        #[arg(required = false, short, long)]
        force: bool,

        /// Skip all prompts and use first
        #[arg(required = false, short, long)]
        yes: bool,

        /// Set portable dir for home & config
        #[arg(
            required = false,
            long, num_args = 0..=1,
            value_hint = ValueHint::AnyPath
        )]
        portable: Option<Option<String>>,

        /// Set portable home
        #[arg(
            required = false,
            long, num_args = 0..=1,
            value_hint = ValueHint::AnyPath,
            conflicts_with = "portable"
        )]
        portable_home: Option<Option<String>>,

        /// Set portable config
        #[arg(
            required = false,
            long, num_args = 0..=1,
            value_hint = ValueHint::AnyPath,
            conflicts_with = "portable"
        )]
        portable_config: Option<Option<String>>,

        /// Set portable share
        #[arg(
            required = false,
            long, num_args = 0..=1,
            value_hint = ValueHint::AnyPath,
            conflicts_with = "portable"
        )]
        portable_share: Option<Option<String>>,

        /// Set portable cache
        #[arg(
            required = false,
            long, num_args = 0..=1,
            value_hint = ValueHint::AnyPath,
            conflicts_with = "portable"
        )]
        portable_cache: Option<Option<String>>,

        /// Don't display notes
        #[arg(required = false, long)]
        no_notes: bool,

        /// Exclude log, build/spec files, and desktop integration files
        ///
        /// Note: This won't prevent desktop integration
        #[arg(required = false, long)]
        binary_only: bool,

        /// Ask for confirmation before installation
        #[arg(required = false, long, short)]
        ask: bool,

        /// Skip checksum verification
        #[arg(required = false, long)]
        no_verify: bool,

        /// Override package name (for URL installs)
        #[arg(required = false, long)]
        name: Option<String>,

        /// Override version (for URL installs)
        #[arg(required = false, long)]
        version: Option<String>,

        /// Override package type (for URL installs, e.g., appimage, flatimage, archive)
        #[arg(required = false, long)]
        pkg_type: Option<String>,

        /// Override package ID (for URL installs)
        #[arg(required = false, long)]
        pkg_id: Option<String>,

        /// Show all available variants for interactive selection
        #[arg(required = false, long)]
        show: bool,
    },

    /// Search package
    #[command(arg_required_else_help = true)]
    #[clap(name = "search", visible_alias = "s", visible_alias = "find")]
    Search {
        /// Query to search
        #[arg(required = true)]
        query: String,

        /// Case sensitive search
        #[arg(required = false, long, alias = "exact")]
        case_sensitive: bool,

        /// Limit number of result
        #[arg(required = false, long)]
        limit: Option<usize>,
    },

    /// Query package info
    #[command(arg_required_else_help = true)]
    #[clap(name = "query", visible_alias = "Q")]
    Query {
        /// Package to query
        #[arg(required = true)]
        query: String,
    },

    /// Remove packages
    #[command(arg_required_else_help = true)]
    #[clap(name = "remove", visible_alias = "r", visible_alias = "del")]
    Remove {
        /// Packages to remove
        #[arg(required = true)]
        packages: Vec<String>,

        /// Skip prompts and use first match
        #[arg(required = false, short, long)]
        yes: bool,

        /// Remove all installed variants
        #[arg(required = false, long)]
        all: bool,
    },

    /// Sync with remote metadata
    #[clap(name = "sync", visible_alias = "S", visible_alias = "fetch")]
    Sync,

    /// Update packages
    #[clap(name = "update", visible_alias = "u", visible_alias = "upgrade")]
    Update {
        /// Packages to update
        #[arg(required = false)]
        packages: Option<Vec<String>>,

        /// Keep old version
        #[arg(required = false, short, long)]
        keep: bool,

        /// Ask for confirmation before update
        #[arg(required = false, long, short)]
        ask: bool,

        /// Skip checksum verification
        #[arg(required = false, long)]
        no_verify: bool,
    },

    /// Show info about installed packages
    #[clap(name = "info", visible_alias = "list-installed")]
    ListInstalledPackages {
        /// Repository to get installed packages for
        #[arg(required = false, long, short)]
        repo_name: Option<String>,

        /// Only show the unique package install count
        #[arg(required = false, long)]
        count: bool,
    },

    /// List all available packages
    #[clap(name = "list", visible_alias = "ls")]
    ListPackages {
        /// Which repository to get the packages from
        #[arg(required = false)]
        repo_name: Option<String>,
    },

    /// Inspect package build log
    #[command(arg_required_else_help = true)]
    #[clap(name = "log")]
    Log {
        /// Package to view log for
        #[arg(required = true)]
        package: String,
    },

    /// Inspect package build script
    #[command(arg_required_else_help = true)]
    #[clap(name = "inspect")]
    Inspect {
        /// Package to view build script for
        #[arg(required = true)]
        package: String,
    },

    /// Run packages without installing to PATH
    #[command(arg_required_else_help = true)]
    #[clap(name = "run", visible_alias = "exec", visible_alias = "execute")]
    Run {
        /// Skip all prompts and use first
        #[arg(required = false, short, long)]
        yes: bool,

        /// Command to execute
        #[arg(required = true)]
        command: Vec<String>,

        /// Package id
        #[arg(required = false, long)]
        pkg_id: Option<String>,

        /// Repo name
        #[arg(required = false, short, long)]
        repo_name: Option<String>,
    },

    /// Use package from different family
    #[command(arg_required_else_help = true)]
    #[clap(name = "use")]
    Use {
        /// The package name to use alternative package for
        #[arg(required = true)]
        package_name: String,
    },

    /// Download arbitrary files
    #[command(arg_required_else_help = true)]
    #[clap(name = "download", visible_alias = "dl")]
    Download {
        /// Links to files
        #[arg(required = false)]
        links: Vec<String>,

        /// Automatically answer 'yes' to all prompts
        /// Skips user interaction and uses default or first options
        #[arg(required = false, short, long)]
        yes: bool,

        /// Output file path
        #[arg(required = false, short, long, value_hint = ValueHint::AnyPath)]
        output: Option<String>,

        /// Regex to select the asset. Only works for github downloads
        #[arg(required = false, short = 'r', long = "regex")]
        regexes: Option<Vec<String>>,

        /// Glob to select the asset.
        #[arg(required = false, short = 'g', long = "glob")]
        globs: Option<Vec<String>>,

        /// Check if the asset contains given string
        #[arg(required = false, short, long = "match")]
        match_keywords: Option<Vec<String>>,

        /// Check if the asset contains given string
        #[arg(required = false, short, long = "exclude")]
        exclude_keywords: Option<Vec<String>>,

        /// Github project
        #[arg(required = false, long)]
        github: Vec<String>,

        /// Gitlab project
        #[arg(required = false, long)]
        gitlab: Vec<String>,

        /// OCI reference
        #[arg(required = false, long)]
        ghcr: Vec<String>,

        /// Whether to use exact case matching for keywords
        #[arg(required = false, long)]
        exact_case: bool,

        /// Extract supported archive automatically
        #[arg(required = false, long)]
        extract: bool,

        /// Directory where to extract the archive
        #[arg(required = false, long)]
        extract_dir: Option<String>,

        /// Skip existing download with same file
        #[arg(required = false, long)]
        skip_existing: bool,

        /// Overwrite existing download with same file
        #[arg(required = false, long)]
        force_overwrite: bool,
    },

    /// Health check
    #[clap(name = "health")]
    Health,

    /// Generate default config
    #[clap(name = "defconfig")]
    DefConfig {
        /// Enable only selected repositories
        #[arg(
            required = false,
            short,
            long,
            num_args = 0..,
            value_delimiter = ',',
            value_parser = parse_default_repos_arg
        )]
        repositories: Vec<String>,
    },

    /// Manage repositories
    #[command(arg_required_else_help = true)]
    #[clap(name = "repo", visible_alias = "repository")]
    Repo {
        #[clap(subcommand)]
        action: RepoAction,
    },

    /// View env
    #[clap(name = "env")]
    Env,

    /// Garbage collection
    #[clap(name = "clean")]
    Clean {
        /// Clean cache
        #[arg(required = false, long)]
        cache: bool,

        /// Clean broken symlinks
        #[arg(required = false, long)]
        broken_symlinks: bool,

        /// Clean broken packages
        #[arg(required = false, long)]
        broken: bool,
    },

    /// Modify the soar installation
    #[cfg(feature = "self")]
    #[command(arg_required_else_help = true)]
    #[clap(name = "self")]
    SelfCmd {
        #[clap(subcommand)]
        action: SelfAction,
    },

    /// Apply declarative package configuration
    #[clap(name = "apply")]
    Apply {
        /// Remove packages not declared in packages.toml
        #[arg(required = false, long)]
        prune: bool,

        /// Show what would be done without making changes
        #[arg(required = false, long)]
        dry_run: bool,

        /// Skip confirmation prompts
        #[arg(required = false, short, long)]
        yes: bool,

        /// Path to packages.toml (default: ~/.config/soar/packages.toml)
        #[arg(required = false, long = "packages", value_hint = ValueHint::FilePath)]
        packages_config: Option<String>,

        /// Skip checksum verification
        #[arg(required = false, long)]
        no_verify: bool,
    },

    /// Generate default packages configuration
    #[clap(name = "defpackages")]
    DefPackages,

    /// Convert JSON metadata to SQLite database
    #[clap(name = "json2db")]
    Json2Db {
        /// Path to input JSON metadata file
        #[arg(required = true, value_hint = ValueHint::FilePath)]
        input: String,

        /// Path to output SQLite database file
        #[arg(required = true, value_hint = ValueHint::FilePath)]
        output: String,

        /// Repository name (default: "custom")
        #[arg(short, long)]
        repo: Option<String>,
    },
}