2
2
3
3
import com .devonfw .tools .ide .common .StepContainer ;
4
4
import com .devonfw .tools .ide .context .IdeContext ;
5
+ import com .devonfw .tools .ide .property .StringProperty ;
5
6
import com .devonfw .tools .ide .repo .CustomTool ;
6
7
import com .devonfw .tools .ide .tool .CustomToolCommandlet ;
7
8
import com .devonfw .tools .ide .tool .ToolCommandlet ;
16
17
*/
17
18
public class UpdateCommandlet extends Commandlet {
18
19
19
- private static final String SETTINGS_REPO_URL = "https://github.com/devonfw/ide-settings" ;
20
+ private static final String DEFAULT_SETTINGS_REPO_URL = "https://github.com/devonfw/ide-settings" ;
21
+
22
+ private final StringProperty settingsRepo ;
20
23
21
24
/**
22
25
* The constructor.
@@ -27,6 +30,7 @@ public UpdateCommandlet(IdeContext context) {
27
30
28
31
super (context );
29
32
addKeyword (getName ());
33
+ settingsRepo = add (new StringProperty ("" , false , "settingsRepository" ));
30
34
}
31
35
32
36
@ Override
@@ -39,8 +43,8 @@ public String getName() {
39
43
public void run () {
40
44
41
45
updateSettings ();
42
- updateSoftware ();
43
- updateRepositories ();
46
+ // updateSoftware();
47
+ // updateRepositories();
44
48
}
45
49
46
50
@@ -50,10 +54,28 @@ private void updateSettings() {
50
54
Path settingsPath = this .context .getSettingsPath ();
51
55
if (Files .isDirectory (settingsPath )) {
52
56
// perform git pull on the settings repo
53
- this .context .gitPullOrClone (settingsPath , SETTINGS_REPO_URL );
57
+ this .context .gitPullOrClone (settingsPath , DEFAULT_SETTINGS_REPO_URL );
54
58
this .context .success ("Successfully updated settings repository." );
55
59
} else {
56
- throw new IllegalStateException ("Cannot find settings repository." );
60
+ // check if a settings repository is given then clone, otherwise prompt user for a repository.
61
+ String repository = settingsRepo .getValue ();
62
+ if (repository == null ) {
63
+ if (this .context .isBatchMode ()) {
64
+ repository = DEFAULT_SETTINGS_REPO_URL ;
65
+ } else {
66
+ this .context .info ("Missing your settings at {} and no SETTINGS_URL is defined." , settingsPath );
67
+ this .context .info ("Further details can be found here:" );
68
+ this .context .info ("https://github.com/devonfw/IDEasy/blob/main/documentation/settings.asciidoc" );
69
+ this .context .info ("Please contact the technical lead of your project to get the SETTINGS_URL for your project." );
70
+ this .context .info ("In case you just want to test IDEasy you may simply hit return to install the default settings." );
71
+ this .context .info ();
72
+ repository = this .context .read ("Settings URL [" + DEFAULT_SETTINGS_REPO_URL +"]: " );
73
+ }
74
+ }
75
+ if (repository .isBlank ()) {
76
+ repository = DEFAULT_SETTINGS_REPO_URL ;
77
+ }
78
+ this .context .gitPullOrClone (settingsPath , repository );
57
79
}
58
80
}
59
81
0 commit comments