• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 12084849850

29 Nov 2024 12:34PM UTC coverage: 67.031% (-0.4%) from 67.412%
12084849850

push

github

web-flow
#758: improve status commandlet (#816)

2500 of 4078 branches covered (61.3%)

Branch coverage included in aggregate %.

6515 of 9371 relevant lines covered (69.52%)

3.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

7.14
cli/src/main/java/com/devonfw/tools/ide/commandlet/StatusCommandlet.java
1
package com.devonfw.tools.ide.commandlet;
2

3
import java.nio.file.Path;
4

5
import com.devonfw.tools.ide.context.GitContext;
6
import com.devonfw.tools.ide.context.IdeContext;
7
import com.devonfw.tools.ide.environment.EnvironmentVariables;
8

9
/**
10
 * {@link Commandlet} to print a status report about IDEasy.
11
 */
12
public class StatusCommandlet extends Commandlet {
13

14
  /**
15
   * The constructor.
16
   *
17
   * @param context the {@link IdeContext}.
18
   */
19
  public StatusCommandlet(IdeContext context) {
20

21
    super(context);
3✔
22
    addKeyword(getName());
4✔
23
  }
1✔
24

25
  @Override
26
  public String getName() {
27

28
    return "status";
2✔
29
  }
30

31
  @Override
32
  public void run() {
33

34
    this.context.logIdeHomeAndRootStatus();
×
35
    logOnlineStatus();
×
36
    logSettingsGitStatus();
×
37
    logSettingsLegacyStatus();
×
38
  }
×
39

40
  private void logSettingsLegacyStatus() {
41
    EnvironmentVariables variables = this.context.getVariables();
×
42
    boolean hasLegacyProperties = false;
×
43
    while (variables != null) {
×
44
      Path legacyProperties = variables.getLegacyPropertiesFilePath();
×
45
      if (legacyProperties != null) {
×
46
        hasLegacyProperties = true;
×
47
        this.context.warning("Found legacy properties {}", legacyProperties);
×
48
      }
49
      variables = variables.getParent();
×
50
    }
×
51
    if (hasLegacyProperties) {
×
52
      this.context.warning(
×
53
          "Your settings are outdated and contain legacy configurations. Please consider upgrading your settings:\nhttps://github.com/devonfw/IDEasy/blob/main/documentation/settings.adoc#upgrade");
54
    }
55
  }
×
56

57
  private void logSettingsGitStatus() {
58
    Path settingsPath = this.context.getSettingsPath();
×
59
    if (settingsPath != null) {
×
60
      GitContext gitContext = this.context.getGitContext();
×
61
      if (gitContext.isRepositoryUpdateAvailable(settingsPath)) {
×
62
        this.context.warning("Your settings are not up-to-date, please run 'ide update'.");
×
63
      } else {
64
        this.context.success("Your settings are up-to-date.");
×
65
      }
66
      String branch = gitContext.determineCurrentBranch(settingsPath);
×
67
      this.context.debug("Your settings branch is {}", branch);
×
68
      if (!"master".equals(branch) && !"main".equals(branch)) {
×
69
        this.context.warning("Your settings are on a custom branch: {}", branch);
×
70
      }
71
    }
72
  }
×
73

74
  private void logOnlineStatus() {
75
    if (this.context.isOfflineMode()) {
×
76
      this.context.warning("You have configured offline mode via CLI.");
×
77
    } else if (this.context.isOnline()) {
×
78
      this.context.success("You are online.");
×
79
    } else {
80
      this.context.warning("You are offline. Check your internet connection and potential proxy settings.");
×
81
    }
82
  }
×
83
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc