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

devonfw / IDEasy / 9903789173

12 Jul 2024 06:58AM UTC coverage: 61.842% (+0.03%) from 61.812%
9903789173

push

github

web-flow
#428: Improve get version and edition (#455)

2008 of 3567 branches covered (56.29%)

Branch coverage included in aggregate %.

5324 of 8289 relevant lines covered (64.23%)

2.82 hits per line

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

72.73
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 void run() {
47

48
    ToolCommandlet commandlet = this.tool.getValue();
5✔
49
    String configuredEdition = commandlet.getConfiguredEdition();
3✔
50

51
    if (this.installed.isTrue() && !this.configured.isTrue()) { // get installed edition
8!
52

53
      VersionIdentifier installedVersion = commandlet.getInstalledVersion();
3✔
54
      if (installedVersion == null) {
2!
55
        this.context.info("No installation of tool {} was found.", commandlet.getName());
11✔
56
        toolInstallInfo(commandlet.getName(), configuredEdition);
6✔
57
      } else {
58
        String installedEdition = commandlet.getInstalledEdition();
×
59
        this.context.info(installedEdition);
×
60
      }
61

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

64
      this.context.info(configuredEdition);
5✔
65

66
    } else { // get both configured and installed edition
67
      String installedEdition = commandlet.getInstalledEdition();
3✔
68

69
      if (configuredEdition.equals(installedEdition)) {
4!
70
        this.context.info(installedEdition);
5✔
71
      } else {
72
        if (installedEdition == null) {
×
73
          this.context.info("No installation of tool {} was found.", commandlet.getName());
×
74
        } else {
75
          this.context.info("The installed edition for tool {} is {}", commandlet.getName(), installedEdition);
×
76
        }
77
        toolInstallInfo(commandlet.getName(), configuredEdition);
×
78
      }
79

80
    }
81

82
  }
1✔
83

84
  private void toolInstallInfo(String toolName, String configuredEdition) {
85

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