Skip to content

Commit c40042f

Browse files
committed
updated updateSettings
when no settingsfolder is found, prompt user for link to clone
1 parent 68ddfa8 commit c40042f

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

cli/src/main/java/com/devonfw/tools/ide/commandlet/UpdateCommandlet.java

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.devonfw.tools.ide.common.StepContainer;
44
import com.devonfw.tools.ide.context.IdeContext;
5+
import com.devonfw.tools.ide.property.StringProperty;
56
import com.devonfw.tools.ide.repo.CustomTool;
67
import com.devonfw.tools.ide.tool.CustomToolCommandlet;
78
import com.devonfw.tools.ide.tool.ToolCommandlet;
@@ -16,7 +17,9 @@
1617
*/
1718
public class UpdateCommandlet extends Commandlet {
1819

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;
2023

2124
/**
2225
* The constructor.
@@ -27,6 +30,7 @@ public UpdateCommandlet(IdeContext context) {
2730

2831
super(context);
2932
addKeyword(getName());
33+
settingsRepo = add(new StringProperty("", false, "settingsRepository"));
3034
}
3135

3236
@Override
@@ -39,8 +43,8 @@ public String getName() {
3943
public void run() {
4044

4145
updateSettings();
42-
updateSoftware();
43-
updateRepositories();
46+
//updateSoftware();
47+
//updateRepositories();
4448
}
4549

4650

@@ -50,10 +54,28 @@ private void updateSettings() {
5054
Path settingsPath = this.context.getSettingsPath();
5155
if (Files.isDirectory(settingsPath)) {
5256
// perform git pull on the settings repo
53-
this.context.gitPullOrClone(settingsPath, SETTINGS_REPO_URL);
57+
this.context.gitPullOrClone(settingsPath, DEFAULT_SETTINGS_REPO_URL);
5458
this.context.success("Successfully updated settings repository.");
5559
} 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);
5779
}
5880
}
5981

cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,14 @@ public <O> O question(String question, O... options) {
698698
return option;
699699
}
700700

701+
702+
public String read(String msg) {
703+
704+
interaction(msg);
705+
return readLine();
706+
}
707+
708+
701709
/**
702710
* @return the input from the end-user (e.g. read from the console).
703711
*/

cli/src/main/java/com/devonfw/tools/ide/context/IdeContext.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ default boolean question(String question) {
177177
@SuppressWarnings("unchecked")
178178
<O> O question(String question, O... options);
179179

180+
String read(String message);
181+
180182
/**
181183
* Will ask the given question. If the user answers with "yes" the method will return and the process can continue.
182184
* Otherwise if the user answers with "no" an exception is thrown to abort further processing.

0 commit comments

Comments
 (0)