-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rs
92 lines (84 loc) · 1.98 KB
/
main.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
use clap::Parser;
use std::path::PathBuf;
use url::Url;
#[derive(Parser)]
#[clap(
version = concat!(env!("CARGO_PKG_VERSION")),
setting = clap::AppSettings::DisableHelpSubcommand,
)]
struct Args {
#[clap(subcommand)]
subcommand: Subcommand,
}
#[derive(Parser)]
enum Subcommand {
#[clap(name = "get-manifest-urls")]
GetManifestUrls(GetManifestUrlsArgs),
#[clap(name = "download-manifest")]
DownloadManifest(DownloadManifestArgs),
#[clap(name = "choose-packages")]
ChoosePackages(ChoosePackagesArgs),
#[clap(name = "download-packages")]
DownloadPackages(DownloadPackagesArgs),
#[clap(name = "extract-packages")]
ExtractPackages(ExtractPackagesArgs),
}
#[derive(Parser)]
struct GetManifestUrlsArgs {
#[clap(long)]
major_version: String,
}
#[derive(Parser)]
struct DownloadManifestArgs {
#[clap(long)]
manifest_url: Url,
#[clap(long)]
sha256: String,
#[clap(long)]
output: PathBuf,
}
#[derive(Parser)]
struct ChoosePackagesArgs {
#[clap(long)]
manifest: PathBuf,
#[clap(long = "package", value_name = "PACKAGE", required = true)]
packages: Vec<String>,
#[clap(long)]
output: PathBuf,
}
#[derive(Parser)]
struct DownloadPackagesArgs {
#[clap(long)]
packages: PathBuf,
#[clap(long)]
cache: PathBuf,
}
#[derive(Parser)]
struct ExtractPackagesArgs {
#[clap(long)]
packages: PathBuf,
#[clap(long)]
cache: PathBuf,
#[clap(long)]
output: PathBuf,
}
fn main() {
let args = Args::parse();
match args.subcommand {
Subcommand::GetManifestUrls(args) => {
windows_sdk::get_manifest_urls(args.major_version);
}
Subcommand::DownloadManifest(args) => {
windows_sdk::download_manifest(args.manifest_url, args.sha256, args.output);
}
Subcommand::ChoosePackages(args) => {
windows_sdk::choose_packages(args.manifest, args.packages, args.output);
}
Subcommand::DownloadPackages(args) => {
windows_sdk::download_packages(args.packages, args.cache);
}
Subcommand::ExtractPackages(args) => {
windows_sdk::extract_packages(args.packages, args.cache, args.output);
}
}
}