-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathcli.rs
More file actions
218 lines (212 loc) · 7.85 KB
/
cli.rs
File metadata and controls
218 lines (212 loc) · 7.85 KB
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
#![deny(missing_docs)]
use clap::{clap_derive::ValueEnum, Parser, Subcommand, ValueHint};
use clap_complete::Shell;
use libium::config::structs::ModLoader;
use std::path::PathBuf;
#[derive(Parser)]
#[clap(author, version, about)]
#[clap(propagate_version = true)]
#[clap(arg_required_else_help = true)]
pub struct Ferium {
#[clap(subcommand)]
pub subcommand: SubCommands,
#[clap(long, short)]
/// Sets the number of worker threads the tokio runtime will use.
/// You can also use the environment variable `TOKIO_WORKER_THREADS`.
pub threads: Option<usize>,
#[clap(long)]
/// Set a GitHub personal access token for increasing the GitHub API rate limit.
/// You can also use the environment variable `GITHUB_TOKEN`.
pub github_token: Option<String>,
#[clap(long)]
/// Set a custom CurseForge API key.
/// You can also use the environment variable `CURSEFORGE_API_KEY`.
pub curseforge_api_key: Option<String>,
#[clap(long, short)]
#[clap(value_hint(ValueHint::FilePath))]
/// Set the file to read the config from.
/// This does not change the `cache` and `tmp` directories.
/// You can also use the environment variable `CONFIG_FILE`.
pub config_file: Option<PathBuf>,
}
#[derive(Subcommand)]
pub enum SubCommands {
/// Add a mod to the profile
Add {
/// The identifier of the mod/project/repository
///
/// The Modrinth project ID is specified at the bottom of the left sidebar under 'Technical information'.
/// You can also use the project slug in the URL.
/// The CurseForge project ID is specified at the top of the right sidebar under 'About Project'.
/// The GitHub identifier is the repository's full name, e.g. `gorilla-devs/ferium`.
identifier: String,
#[clap(long)]
/// The game version will not be checked for this mod
dont_check_game_version: bool,
#[clap(long)]
/// The mod loader will not be checked for this mod
dont_check_mod_loader: bool,
#[clap(long)]
#[clap(value_enum)]
/// Select which dependencies should be added
dependencies: Option<DependencyLevel>,
},
/// Print shell auto completions for the specified shell
Complete {
#[clap(value_enum)]
/// The shell to generate auto completions for
shell: Shell,
},
/// List all the mods in the profile, and with some their metadata if verbose
List {
#[clap(long, short)]
/// Show additional information about the mod
verbose: bool,
#[clap(long, short)]
/// Output information in markdown format and alphabetical order
///
/// Useful for creating modpack mod lists.
/// Complements the verbose flag.
markdown: bool,
},
#[clap(arg_required_else_help = true)]
/// Add, configure, delete, switch, list, or upgrade modpacks
Modpack {
#[clap(subcommand)]
subcommand: ModpackSubCommands,
},
#[clap(arg_required_else_help = true)]
/// Create, configure, delete, switch, or list profiles
Profile {
#[clap(subcommand)]
subcommand: ProfileSubCommands,
},
/// Remove mods and repositories from the profile.
/// Optionally, provide a list of names or IDs of the mods to remove.
Remove {
/// List of project IDs or case-insensitive names of mods to remove
mod_names: Vec<String>,
},
/// Download and install the latest version of the mods specified
Upgrade {
#[clap(long, short)]
/// Don’t print compatible mods
short: bool,
},
}
#[derive(Subcommand)]
pub enum ProfileSubCommands {
/// Configure the current profile's name, Minecraft version, mod loader, and output directory.
/// Optionally, provide the settings to change as arguments.
Configure {
#[clap(long, short = 'v')]
/// The Minecraft version to check compatibility for
game_version: Option<String>,
#[clap(long, short)]
#[clap(value_enum)]
/// The mod loader to check compatibility for
mod_loader: Option<ModLoader>,
#[clap(long, short)]
/// The name of the profile
name: Option<String>,
#[clap(long, short)]
#[clap(value_hint(ValueHint::DirPath))]
/// The directory to output mods to
output_dir: Option<PathBuf>,
},
/// Create a new profile.
/// Optionally, provide the settings as arguments.
/// Use the import flag to import mods from another profile.
Create {
#[clap(long, short)]
#[allow(clippy::option_option)]
/// Copy over the mods from an existing profile.
/// Optionally, provide the name of the profile to import mods from.
import: Option<Option<String>>,
#[clap(long, short = 'v')]
/// The Minecraft version to check compatibility for
game_version: Option<String>,
#[clap(long, short)]
#[clap(value_enum)]
/// The mod loader to check compatibility for
mod_loader: Option<ModLoader>,
#[clap(long, short)]
/// The name of the profile
name: Option<String>,
#[clap(long, short)]
#[clap(value_hint(ValueHint::DirPath))]
/// The directory to output mods to
output_dir: Option<PathBuf>,
},
/// Delete a profile.
/// Optionally, provide the name of the profile to delete.
Delete {
/// The name of the profile to delete
profile_name: Option<String>,
},
/// List all the profiles with their data
List,
/// Switch between different profiles.
/// Optionally, provide the name of the profile to switch to.
Switch {
/// The name of the profile to switch to
profile_name: Option<String>,
},
}
#[derive(Subcommand)]
pub enum ModpackSubCommands {
/// Add a modpack to the config
Add {
/// The identifier of the modpack/project
///
/// The Modrinth project ID is specified at the bottom of the left sidebar under 'Technical information'.
/// You can also use the project slug for this.
/// The CurseForge project ID is specified at the top of the right sidebar under 'About Project'.
identifier: String,
#[clap(long, short)]
#[clap(value_hint(ValueHint::DirPath))]
/// The Minecraft instance directory to install the modpack to
output_dir: Option<PathBuf>,
#[clap(long, short)]
/// Whether to install the modpack's overrides to the output directory.
/// This will override existing files when upgrading.
install_overrides: Option<bool>,
},
/// Configure the current modpack's output directory and installation of overrides.
/// Optionally, provide the settings to change as arguments.
Configure {
#[clap(long, short)]
#[clap(value_hint(ValueHint::DirPath))]
/// The Minecraft instance directory to install the modpack to
output_dir: Option<PathBuf>,
#[clap(long, short)]
/// Whether to install the modpack's overrides to the output directory.
/// This will override existing files when upgrading.
install_overrides: Option<bool>,
},
/// Delete a modpack.
/// Optionally, provide the name of the modpack to delete.
Delete {
/// The name of the modpack to delete
modpack_name: Option<String>,
},
/// List all the modpacks
List,
/// Switch between different modpacks.
/// Optionally, provide the name of the modpack to switch to.
Switch {
/// The name of the modpack to switch to
modpack_name: Option<String>,
},
/// Download and install the latest version of the modpack
Upgrade,
}
#[derive(Clone, PartialEq, Eq, ValueEnum)]
pub enum DependencyLevel {
/// Do not add any dependencies
None,
/// Add only required dependencies
Required,
/// Add all dependencies
All,
}