dev_scripts/cli.rs
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
use std::path::PathBuf;
use clap::{ArgAction, Parser, ValueEnum};
use strum::Display;
#[derive(Parser, Debug)]
#[clap(name = "ALPM Dev Scripts", about = "Dev scripts for the ALPM project")]
pub struct Cli {
/// Verbose mode (-v, -vv)
#[clap(short, long, action = ArgAction::Count)]
pub verbose: u8,
#[clap(subcommand)]
pub cmd: Command,
}
#[derive(Parser, Debug)]
pub enum Command {
/// Tests file formats with real-world files from official repositories.
TestFiles {
#[clap(subcommand)]
cmd: TestFilesCmd,
},
}
#[derive(Parser, ValueEnum, Display, Debug, Clone, Copy, PartialEq, Eq)]
pub enum TestFileType {
#[strum(to_string = ".BUILDINFO")]
BuildInfo,
#[strum(to_string = ".SRCINFO")]
SrcInfo,
#[strum(to_string = ".PKGINFO")]
PkgInfo,
#[strum(to_string = ".MTREE")]
MTree,
#[strum(to_string = "desc")]
RemoteDesc,
#[strum(to_string = "files")]
RemoteFiles,
#[strum(to_string = "desc")]
LocalDesc,
#[strum(to_string = "files")]
LocalFiles,
}
#[derive(Parser, Debug)]
pub enum TestFilesCmd {
/// Download/synchronize files for testing to this machine.
///
/// Each type of file can be downloaded individually.
Test {
// Where the local testing data is located.
// Defaults to `~/.cache/alpm/testing`
#[arg(short, long)]
test_data_dir: Option<PathBuf>,
/// The type of file that should be tested.
file_type: TestFileType,
},
/// Download/synchronize files for testing to this machine.
///
/// Each type of file can be downloaded individually.
Download {
// Where the testing data should be downloaded to.
//
// Defaults to `$XDG_CACHE_HOME/alpm/testing`.
// if `$XDG_CACHE_HOME` isn't set, it falls back to to `~/.cache/alpm/testing`.
#[arg(short, long)]
destination: Option<PathBuf>,
#[clap(subcommand)]
source: DownloadCmd,
},
/// Remove or clean downloaded local testing files.
Clean {
// Where the testing data has been downloaded to.
// Defaults to `~/.cache/alpm/testing`
#[arg(short, long)]
destination: Option<PathBuf>,
#[clap(subcommand)]
source: CleanCmd,
},
}
#[derive(Parser, Debug)]
pub enum DownloadCmd {
/// Download all official package source repositories
///
/// This is done by querying all active repositories via the arch web API
/// (<https://archlinux.org/packages/pkgbase-maintainer>) and cloning the respective
/// package source repositories via git.
///
/// This command differs from `pkgctl repo clone --universe` in so far that it
/// also updates git repositories and removes repositories that're no longer used.
///
/// The repositories contain the following file types for each package.
/// - .SRCINFO
PkgSrcRepositories {},
/// Create a copy of a mirror's pacman database.
///
/// The database contains the following file types for each package.
/// - `files`
/// - `desc`
Databases {
/// The domain + base path under which the mirror can be found.
///
/// The mirror must support the `rsync` protocol
#[arg(short, long, env, default_value = "mirror.pseudoform.org/packages")]
mirror: String,
},
/// The packages contain the following file types for each package.
/// - `.INSTALL`
/// - `.BUILDINFO`
/// - `.MTREE`
/// - `.PKGINFO`
Packages {
/// The domain + base path under which the mirror can be found.
///
/// The mirror must support the `rsync` protocol
#[arg(short, long, env, default_value = "mirror.pseudoform.org/packages")]
mirror: String,
},
}
#[derive(Parser, Debug)]
pub enum CleanCmd {
/// Remove all package source repositories and .SRCINFO files
PkgSrcRepositories,
/// Remove extracted repository sync database files and tarballs.
Databases,
/// Remove all downloaded packages and any other files extracted from them.
Packages,
}