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

devonfw / IDEasy / 9904178931

12 Jul 2024 07:32AM UTC coverage: 61.387% (-0.5%) from 61.842%
9904178931

push

github

web-flow
#400: fix error handling for undefined IDE_ROOT and IDE_HOME (#476)

1997 of 3575 branches covered (55.86%)

Branch coverage included in aggregate %.

5297 of 8307 relevant lines covered (63.77%)

2.8 hits per line

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

71.11
cli/src/main/java/com/devonfw/tools/ide/commandlet/EditionGetCommandlet.java
1
package com.devonfw.tools.ide.commandlet;
2

3
import com.devonfw.tools.ide.context.IdeContext;
4
import com.devonfw.tools.ide.property.FlagProperty;
5
import com.devonfw.tools.ide.property.ToolProperty;
6
import com.devonfw.tools.ide.tool.ToolCommandlet;
7
import com.devonfw.tools.ide.version.VersionIdentifier;
8

9
/**
10
 * An internal {@link Commandlet} to get the installed edition for a tool.
11
 *
12
 * @see ToolCommandlet#getInstalledEdition()
13
 */
14
public class EditionGetCommandlet extends Commandlet {
15

16
  /** The tool to get the edition of. */
17
  public final ToolProperty tool;
18

19
  /** Flag to get the configured version. */
20
  public final FlagProperty configured;
21

22
  /** Flag to get the installed version. */
23
  public final FlagProperty installed;
24

25
  /**
26
   * The constructor.
27
   *
28
   * @param context the {@link IdeContext}.
29
   */
30
  public EditionGetCommandlet(IdeContext context) {
31

32
    super(context);
3✔
33
    addKeyword(getName());
4✔
34
    this.tool = add(new ToolProperty("", true, "tool"));
11✔
35
    this.configured = add(new FlagProperty("--configured", false, null));
11✔
36
    this.installed = add(new FlagProperty("--installed", false, null));
11✔
37
  }
1✔
38

39
  @Override
40
  public String getName() {
41

42
    return "get-edition";
2✔
43
  }
44

45
  @Override
46
  public boolean isProcessableOutput() {
47

48
    return true;
×
49
  }
50

51
  @Override
52
  public void run() {
53

54
    ToolCommandlet commandlet = this.tool.getValue();
5✔
55
    String configuredEdition = commandlet.getConfiguredEdition();
3✔
56

57
    if (this.installed.isTrue() && !this.configured.isTrue()) { // get installed edition
8!
58

59
      VersionIdentifier installedVersion = commandlet.getInstalledVersion();
3✔
60
      if (installedVersion == null) {
2!
61
        this.context.info("No installation of tool {} was found.", commandlet.getName());
11✔
62
        toolInstallInfo(commandlet.getName(), configuredEdition);
6✔
63
      } else {
64
        String installedEdition = commandlet.getInstalledEdition();
×
65
        this.context.info(installedEdition);
×
66
      }
67

68
    } else if (!this.installed.isTrue() && this.configured.isTrue()) { // get configured edition
9!
69

70
      this.context.info(configuredEdition);
5✔
71

72
    } else { // get both configured and installed edition
73
      String installedEdition = commandlet.getInstalledEdition();
3✔
74

75
      if (configuredEdition.equals(installedEdition)) {
4!
76
        this.context.info(installedEdition);
5✔
77
      } else {
78
        if (installedEdition == null) {
×
79
          this.context.info("No installation of tool {} was found.", commandlet.getName());
×
80
        } else {
81
          this.context.info("The installed edition for tool {} is {}", commandlet.getName(), installedEdition);
×
82
        }
83
        toolInstallInfo(commandlet.getName(), configuredEdition);
×
84
      }
85

86
    }
87

88
  }
1✔
89

90
  private void toolInstallInfo(String toolName, String configuredEdition) {
91

92
    this.context.info("The configured edition for tool {} is {}", toolName, configuredEdition);
14✔
93
    this.context.info("To install that edition call the following command:");
4✔
94
    this.context.info("ide install {}", toolName);
10✔
95
  }
1✔
96
}
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