11use std:: { io:: Write , path:: PathBuf } ;
22
33use clap:: { ArgMatches , Command , arg, command, value_parser} ;
4+ use log:: info;
45
56use crate :: {
67 errors:: InstallerError ,
@@ -10,6 +11,12 @@ use crate::{
1011 } ,
1112} ;
1213
14+ #[ derive( PartialEq , Eq ) ]
15+ enum InstallationResult {
16+ Installed ,
17+ NotInstalled ,
18+ }
19+
1320pub async fn run ( ) {
1421 let matches = command ! ( )
1522 . arg_required_else_help ( true )
@@ -40,7 +47,7 @@ pub async fn run() {
4047 . default_value ( super :: current_location ( ) )
4148 . value_parser ( value_parser ! ( PathBuf ) ) ,
4249 )
43- . arg ( arg ! ( -z --"generate-zip" <VALUE > "Whether to generate an instance zip instead of installing into the directory" )
50+ . arg ( arg ! ( -z --"generate-zip" <VALUE > "Whether to generate an instance zip instead of installing an instance into the directory" )
4451 . default_value ( "true" ) . value_parser ( value_parser ! ( bool ) ) )
4552 . arg ( arg ! ( -c --"copy-profile-path" <VALUE > "Whether to copy the path of the generated profile to the clipboard" )
4653 . default_value ( "false" ) . value_parser ( value_parser ! ( bool ) )
@@ -67,7 +74,8 @@ pub async fn run() {
6774 . long_flag ( "list-game-versions" )
6875 . long_flag_alias ( "list-minecraft-versions" )
6976 . about ( "List supported game versions" )
70- . arg ( arg ! ( -s --"show-snapshots" "Include snapshot versions" ) ) ,
77+ . arg ( arg ! ( -s --"show-snapshots" "Include snapshot versions" ) )
78+ . arg ( arg ! ( --"show-historical" "Include historical versions" ) ) ,
7179 )
7280 . subcommand (
7381 Command :: new ( "loader-versions" )
@@ -82,7 +90,16 @@ pub async fn run() {
8290 . get_matches ( ) ;
8391
8492 match parse ( matches) . await {
85- Ok ( _) => { }
93+ Ok ( r) => {
94+ if r == InstallationResult :: Installed {
95+ info ! ( "Installation complete!" ) ;
96+ info ! ( "Ornithe has been successfully installed." ) ;
97+ info ! (
98+ "Most mods require that you also download the Ornithe Standard Libraries mod and place it in your mods folder."
99+ ) ;
100+ info ! ( "You can find it at {}" , crate :: OSL_MODRINTH_URL ) ;
101+ }
102+ }
86103 Err ( e) => {
87104 std:: io:: stderr ( )
88105 . write_all ( ( "Failed to load Ornithe Installer CLI: " . to_owned ( ) + & e. 0 ) . as_bytes ( ) )
@@ -91,7 +108,7 @@ pub async fn run() {
91108 }
92109}
93110
94- async fn parse ( matches : ArgMatches ) -> Result < ( ) , InstallerError > {
111+ async fn parse ( matches : ArgMatches ) -> Result < InstallationResult , InstallerError > {
95112 if let Some ( matches) = matches. subcommand_matches ( "loader-versions" ) {
96113 let versions = crate :: net:: meta:: fetch_loader_versions ( ) . await ?;
97114 let loader_type = get_loader_type ( matches) ?;
@@ -120,7 +137,7 @@ async fn parse(matches: ArgMatches) -> Result<(), InstallerError> {
120137 ) ?;
121138 writeln ! ( std:: io:: stdout( ) , "{}" , out) ?;
122139
123- return Ok ( ( ) ) ;
140+ return Ok ( InstallationResult :: NotInstalled ) ;
124141 }
125142
126143 let minecraft_versions = crate :: net:: manifest:: fetch_versions ( ) . await ?;
@@ -140,14 +157,26 @@ async fn parse(matches: ArgMatches) -> Result<(), InstallerError> {
140157 if let Some ( matches) = matches. subcommand_matches ( "game-versions" ) {
141158 let mut out = String :: new ( ) ;
142159 let snapshots = matches. get_flag ( "show-snapshots" ) ;
160+ let historical = matches. get_flag ( "show-historical" ) ;
143161 for version in available_minecraft_versions {
144- if snapshots || version. _type == "release" {
162+ let mut displayed = if snapshots && historical {
163+ true
164+ } else {
165+ version. is_release ( )
166+ } ;
167+ if !displayed && snapshots {
168+ displayed |= version. is_snapshot ( ) ;
169+ }
170+ if !displayed && historical {
171+ displayed |= version. is_historical ( ) ;
172+ }
173+ if displayed {
145174 out += & ( version. id . clone ( ) + " " ) ;
146175 }
147176 }
148177 writeln ! ( std:: io:: stdout( ) , "Available Minecraft versions:\n " ) ?;
149178 writeln ! ( std:: io:: stdout( ) , "{}" , out) ?;
150- return Ok ( ( ) ) ;
179+ return Ok ( InstallationResult :: NotInstalled ) ;
151180 }
152181
153182 let loader_versions = crate :: net:: meta:: fetch_loader_versions ( ) . await ?;
@@ -159,14 +188,15 @@ async fn parse(matches: ArgMatches) -> Result<(), InstallerError> {
159188 let loader_version = get_loader_version ( matches, loader_versions) ?;
160189 let location = matches. get_one :: < PathBuf > ( "dir" ) . unwrap ( ) . clone ( ) ;
161190 let create_profile = matches. get_flag ( "generate-profile" ) ;
162- return crate :: actions:: client:: install (
191+ crate :: actions:: client:: install (
163192 minecraft_version,
164193 loader_type,
165194 loader_version,
166195 location,
167196 create_profile,
168197 )
169- . await ;
198+ . await ?;
199+ return Ok ( InstallationResult :: Installed ) ;
170200 }
171201
172202 if let Some ( matches) = matches. subcommand_matches ( "server" ) {
@@ -178,24 +208,26 @@ async fn parse(matches: ArgMatches) -> Result<(), InstallerError> {
178208 if let Some ( matches) = matches. subcommand_matches ( "run" ) {
179209 let java = matches. get_one :: < PathBuf > ( "java" ) ;
180210 let run_args = matches. get_one :: < String > ( "args" ) ;
181- return crate :: actions:: server:: install_and_run (
211+ crate :: actions:: server:: install_and_run (
182212 minecraft_version,
183213 loader_type,
184214 loader_version,
185215 location,
186216 java,
187217 run_args. map ( |s| s. split ( " " ) ) ,
188218 )
189- . await ;
219+ . await ?;
220+ return Ok ( InstallationResult :: Installed ) ;
190221 }
191- return crate :: actions:: server:: install (
222+ crate :: actions:: server:: install (
192223 minecraft_version,
193224 loader_type,
194225 loader_version,
195226 location,
196227 matches. get_flag ( "download-minecraft" ) ,
197228 )
198- . await ;
229+ . await ?;
230+ return Ok ( InstallationResult :: Installed ) ;
199231 }
200232
201233 if let Some ( matches) = matches. subcommand_matches ( "mmc" ) {
@@ -209,18 +241,19 @@ async fn parse(matches: ArgMatches) -> Result<(), InstallerError> {
209241 . unwrap ( )
210242 . clone ( ) ;
211243 let generate_zip = matches. get_one :: < bool > ( "generate-zip" ) . unwrap ( ) . clone ( ) ;
212- return crate :: actions:: mmc_pack:: install (
244+ crate :: actions:: mmc_pack:: install (
213245 minecraft_version,
214246 loader_type,
215247 loader_version,
216248 output_dir,
217249 copy_profile_path,
218250 generate_zip,
219251 )
220- . await ;
252+ . await ?;
253+ return Ok ( InstallationResult :: Installed ) ;
221254 }
222255
223- Ok ( ( ) )
256+ Ok ( InstallationResult :: NotInstalled )
224257}
225258
226259fn get_minecraft_version (
0 commit comments