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

devonfw / IDEasy / 12429379558

20 Dec 2024 10:01AM UTC coverage: 67.345% (-0.1%) from 67.478%
12429379558

Pull #903

github

web-flow
Merge d3d2a74f1 into bc0d144fa
Pull Request #903: #898 improved feedback messages

2576 of 4174 branches covered (61.72%)

Branch coverage included in aggregate %.

6659 of 9539 relevant lines covered (69.81%)

3.07 hits per line

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

70.69
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.log.IdeLogLevel;
5
import com.devonfw.tools.ide.log.IdeSubLogger;
6
import com.devonfw.tools.ide.property.FlagProperty;
7
import com.devonfw.tools.ide.property.ToolProperty;
8
import com.devonfw.tools.ide.tool.ToolCommandlet;
9

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

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

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

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

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

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

40
  @Override
41
  public String getName() {
42

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

46
  @Override
47
  public boolean isProcessableOutput() {
48

49
    return true;
×
50
  }
51

52
  @Override
53
  public void run() {
54

55
    ToolCommandlet commandlet = this.tool.getValue();
5✔
56
    String configuredEdition = commandlet.getConfiguredEdition();
3✔
57
    String installedEdition = commandlet.getInstalledEdition();
3✔
58
    IdeSubLogger logger = this.context.level(IdeLogLevel.PROCESSABLE);
5✔
59
    if (this.installed.isTrue() && !this.configured.isTrue()) { // get installed edition
8!
60
      if (commandlet.getInstalledVersion() == null) {
3✔
61
        // note: getInstalledEdition() will fallback to configured edition and not return null, therefore we use getInstalledVersion()
62
        toolInstallInfo(commandlet.getName(), configuredEdition, null, commandlet);
8✔
63
      } else {
64
        logger.log(installedEdition);
4✔
65
      }
66
    } else if (!this.installed.isTrue() && this.configured.isTrue()) { // get configured edition
8!
67
      logger.log(configuredEdition);
4✔
68
    } else if (this.installed.isTrue() && this.configured.isTrue()) { // get both configured and installed edition
4!
69
      logger.log(configuredEdition);
×
70
      if (!configuredEdition.equals(installedEdition)) {
×
71
        if (commandlet.getInstalledVersion() != null) {
×
72
          logger.log(installedEdition);
×
73
        } else {
74
          logger.log("No installed edition detected");
×
75
        }
76
      }
77
    } else { // get configured or installed depending on if the tool is installed or not
78
      if (commandlet.getInstalledVersion() == null) {
3✔
79
        logger.log(configuredEdition);
4✔
80
      } else {
81
        logger.log(installedEdition);
3✔
82
      }
83
    }
84
  }
1✔
85

86
  private void toolInstallInfo(String toolName, String configuredEdition, String installedEdition, ToolCommandlet commandlet) {
87

88
    IdeSubLogger logger = this.context.level(IdeLogLevel.PROCESSABLE);
5✔
89
    if (installedEdition == null) {
2!
90
      logger.log("No installation of tool {} was found.", commandlet.getName());
12✔
91
    } else {
92
      logger.log("The installed edition for tool {} is {}", commandlet.getName(), installedEdition);
×
93
    }
94
    logger.log("The configured edition for tool {} is {}", toolName, configuredEdition);
14✔
95
    logger.log("To install that edition call the following command:");
3✔
96
    logger.log("ide install {}", toolName);
10✔
97
  }
1✔
98
}
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