@@ -4,6 +4,7 @@ use std::process::exit;
44use std:: fs;
55use serde:: { Deserialize , Serialize } ;
66use directories:: BaseDirs ;
7+ use colored:: * ;
78
89#[ derive( Serialize , Deserialize , Clone ) ]
910#[ serde( rename_all = "kebab-case" ) ]
@@ -17,14 +18,14 @@ pub struct Installation {
1718pub struct Config {
1819 pub default_installation : usize ,
1920 pub working_installation : Option < usize > ,
20- pub installations : Vec < Installation > ,
21+ pub installations : Option < Vec < Installation > > ,
2122 pub default_developer : Option < String > ,
2223}
2324
2425static mut CONFIG : Config = Config {
2526 default_installation : 0 ,
2627 working_installation : None ,
27- installations : vec ! ( ) ,
28+ installations : None ,
2829 default_developer : None ,
2930} ;
3031
@@ -50,11 +51,17 @@ impl Config {
5051 let config_json = Config :: data_dir ( ) . join ( "config.json" ) ;
5152 if !config_json. exists ( ) {
5253 println ! (
53- "It seems you don't have Geode installed! \
54+ "{}{}{}{}" ,
55+ "WARNING: It seems you don't have Geode installed! \
5456 Please install Geode first using the official installer \
55- (https://github.com/geode-sdk/installer/releases/latest)"
57+ (". yellow( ) ,
58+ "https://github.com/geode-sdk/installer/releases/latest" . cyan( ) ,
59+ ")" . yellow( ) ,
60+ "\n You may still use the CLI, but be warned that certain \
61+ operations will cause crashes.\n ". purple( )
5662 ) ;
57- exit ( 1 ) ;
63+ fs:: create_dir_all ( Config :: data_dir ( ) ) . unwrap ( ) ;
64+ return ;
5865 }
5966 CONFIG = match serde_json:: from_str (
6067 & fs:: read_to_string ( & config_json) . unwrap ( )
@@ -65,13 +72,18 @@ impl Config {
6572 exit ( 1 ) ;
6673 }
6774 } ;
68- if CONFIG . installations . len ( ) == 0 {
75+ if CONFIG . installations . is_none ( ) {
6976 println ! (
70- "It seems you don't have any installations of Geode! \
77+ "{}{}{}{}" ,
78+ "WARNING: It seems you don't have any installations of Geode! \
7179 Please install Geode first using the official installer \
72- (https://github.com/geode-sdk/installer/releases/latest)"
80+ (". yellow( ) ,
81+ "https://github.com/geode-sdk/installer/releases/latest" . cyan( ) ,
82+ ")" . yellow( ) ,
83+ "\n You may still use the CLI, but be warned that certain \
84+ operations will cause crashes.\n ". purple( )
7385 ) ;
74- exit ( 1 ) ;
86+ return ;
7587 }
7688 if CONFIG . working_installation . is_none ( ) {
7789 CONFIG . working_installation = Some ( CONFIG . default_installation ) ;
@@ -93,6 +105,8 @@ impl Config {
93105 }
94106
95107 pub fn work_inst ( ) -> & ' static Installation {
96- & Config :: get ( ) . installations [ Config :: get ( ) . working_installation . unwrap ( ) ]
108+ & Config :: get ( ) . installations . as_ref ( ) . unwrap ( ) [
109+ Config :: get ( ) . working_installation . unwrap ( )
110+ ]
97111 }
98112}
0 commit comments