@@ -55,12 +55,15 @@ public int config() throws Exception {
5555
5656 @ Command (name = "clone" )
5757 public int cloneCmd (@ Parameters (index = "0" ) String url ) {
58- String userHome = System .getProperty ("user.home" ); // Get User Home Directory: /home/user_name
59- Path configPath = Paths .get (userHome + "/.config/starfix.yaml" );
60-
61- //Check if config file does not exist
62- if (!Files .exists (configPath )){
63- defaultConfig ();
58+ File configFile = getConfigFile ();
59+
60+ try {
61+ if (!configFile .exists ()) {
62+ defaultConfig ();
63+ }
64+ } catch (Exception e ) {
65+ e .printStackTrace ();
66+
6467 }
6568
6669 CloneUrl cloneUrl = new CloneUrl (url );
@@ -156,18 +159,13 @@ public static File getConfigFile() {
156159 public void defaultConfig () {
157160 String path_env = System .getenv ("Path" ); // System PATH variable
158161 clone_path = System .getProperty ("user.home" ) + "/code" ; // set clone_path to /home/user_name/code
159- File configFile = getConfigFile ();
160162
161163 try {
162- configFile .createNewFile ();
163-
164164 if (isWindows ()){// check if Windows OS
165165 if (path_env .contains ("Microsoft VS Code" )){ // If PATH has VScode
166166 ide = "code.cmd" ;
167- writeToYAMLFile (ide , clone_path ,configFile );
168167 } else if (path_env .contains ("IntelliJ IDEA" )){ // If PATH has IntelliJ
169168 ide = "idea64.exe" ;
170- writeToYAMLFile (ide , clone_path ,configFile );
171169 }
172170 }
173171 // check if Linux OS
@@ -181,16 +179,6 @@ public void defaultConfig() {
181179
182180 }
183181 }
184- // Function to write configurations to the YAML FILE
185- public void writeToYAMLFile (String ide , String clone_path , File configFile ) throws Exception {
186- ObjectMapper mapper = new ObjectMapper (new YAMLFactory ());
187- Properties configuration = new Properties ();
188-
189- configuration .put ("ide" , ide );
190- configuration .put ("clone_path" ,clone_path );
191- mapper .writeValue (configFile , configuration );
192- }
193-
194182 // Function to edit configuration and serves for command line starfix config
195183 // editor
196184 public void editConfig () throws Exception {
0 commit comments