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

devonfw / IDEasy / 13440922988

20 Feb 2025 05:16PM UTC coverage: 67.945% (-0.01%) from 67.959%
13440922988

push

github

web-flow
#1053: fix setup #1044: setup rewritten in Java (#1055)

Co-authored-by: jan-vcapgemini <59438728+jan-vcapgemini@users.noreply.github.com>

2992 of 4849 branches covered (61.7%)

Branch coverage included in aggregate %.

7765 of 10983 relevant lines covered (70.7%)

3.08 hits per line

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

65.52
cli/src/main/java/com/devonfw/tools/ide/commandlet/InstallCommandlet.java
1
package com.devonfw.tools.ide.commandlet;
2

3
import java.nio.file.Path;
4

5
import com.devonfw.tools.ide.context.IdeContext;
6
import com.devonfw.tools.ide.property.ToolProperty;
7
import com.devonfw.tools.ide.property.VersionProperty;
8
import com.devonfw.tools.ide.tool.IdeasyCommandlet;
9
import com.devonfw.tools.ide.tool.ToolCommandlet;
10
import com.devonfw.tools.ide.version.VersionIdentifier;
11

12
/**
13
 * {@link Commandlet} to install a tool.
14
 *
15
 * @see ToolCommandlet#install()
16
 */
17
public class InstallCommandlet extends Commandlet {
18

19
  /** The tool to install. */
20
  public final ToolProperty tool;
21

22
  /** The optional version to set and install. */
23
  public final VersionProperty version;
24

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

32
    super(context);
3✔
33
    addKeyword(getName());
4✔
34
    this.tool = add(new ToolProperty("", false, "tool"));
11✔
35
    this.version = add(new VersionProperty("", false, "version"));
11✔
36
  }
1✔
37

38
  @Override
39
  public String getName() {
40

41
    return "install";
2✔
42
  }
43

44
  @Override
45
  public boolean isIdeRootRequired() {
46

47
    return this.tool.getValueCount() > 0;
6!
48
  }
49

50
  @Override
51
  public void run() {
52

53
    if (this.tool.getValueCount() == 0) {
4!
54
      if (!this.context.isForceMode()) {
×
55
        this.context.askToContinue("Sub-command install without any further arguments will perform the initial installation of IDEasy.\n"
×
56
            + "Since this is typically not to be called manually, you may have forgotten to specify the tool to install as extra argument.\n"
57
            + "The current command will install IDEasy on your computer. Are you sure?");
58
      }
59
      IdeasyCommandlet ideasy = new IdeasyCommandlet(this.context);
×
60
      Path cwd = Path.of("").toAbsolutePath();
×
61
      ideasy.installIdeasy(cwd);
×
62
      return;
×
63
    }
64
    ToolCommandlet commandlet = this.tool.getValue();
5✔
65
    VersionIdentifier versionIdentifier = this.version.getValue();
5✔
66
    if (versionIdentifier != null) {
2✔
67
      commandlet.setVersion(versionIdentifier, false);
4✔
68
    }
69
    commandlet.install(false);
4✔
70
  }
1✔
71

72
  @Override
73
  public ToolCommandlet getToolForCompletion() {
74

75
    return this.tool.getValue();
5✔
76
  }
77
}
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