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

devonfw / IDEasy / 10214921211

02 Aug 2024 11:35AM UTC coverage: 62.685% (+0.02%) from 62.663%
10214921211

push

github

web-flow
#430: Add source of env variable for debugging (#482)

2075 of 3645 branches covered (56.93%)

Branch coverage included in aggregate %.

5498 of 8436 relevant lines covered (65.17%)

2.88 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/EnvironmentCommandlet.java
1
package com.devonfw.tools.ide.commandlet;
2

3
import java.util.Collection;
4
import java.util.stream.Collectors;
5

6
import com.devonfw.tools.ide.context.AbstractIdeContext;
7
import com.devonfw.tools.ide.context.IdeContext;
8
import com.devonfw.tools.ide.environment.VariableLine;
9
import com.devonfw.tools.ide.os.WindowsPathSyntax;
10
import com.devonfw.tools.ide.property.FlagProperty;
11

12
/**
13
 * {@link Commandlet} to print the environment variables.
14
 */
15
public final class EnvironmentCommandlet extends Commandlet {
16

17
  /** {@link FlagProperty} to enable Bash (MSys) path conversion on Windows. */
18
  public final FlagProperty bash;
19

20
  /**
21
   * The constructor.
22
   *
23
   * @param context the {@link IdeContext}.
24
   */
25
  public EnvironmentCommandlet(IdeContext context) {
26

27
    super(context);
3✔
28
    addKeyword(getName());
4✔
29
    this.bash = add(new FlagProperty("--bash", false, null));
11✔
30
  }
1✔
31

32
  @Override
33
  public String getName() {
34

35
    return "env";
2✔
36
  }
37

38
  @Override
39
  public boolean isIdeHomeRequired() {
40

41
    return true;
2✔
42
  }
43

44
  @Override
45
  public boolean isProcessableOutput() {
46

47
    return true;
×
48
  }
49

50
  @Override
51
  public void run() {
52

53
    WindowsPathSyntax pathSyntax = null;
2✔
54
    if (this.context.getSystemInfo().isWindows()) {
5!
55
      if (this.bash.isTrue()) {
×
56
        pathSyntax = WindowsPathSyntax.MSYS;
×
57
      } else {
58
        pathSyntax = WindowsPathSyntax.WINDOWS;
×
59
      }
60
    }
61
    ((AbstractIdeContext) this.context).setPathSyntax(pathSyntax);
5✔
62
    Collection<VariableLine> variables = this.context.getVariables().collectVariables();
5✔
63
    if (this.context.debug().isEnabled()) {
5!
64
      for (String source : variables.stream().map(VariableLine::getSource).collect(Collectors.toSet())) {
16✔
65
        this.context.debug("from {}:", source);
10✔
66
        for (VariableLine line : variables) {
10✔
67
          if (line.getSource().equals(source)) {
5✔
68
            printEnvLine(line);
3✔
69
          }
70
        }
1✔
71
      }
2✔
72
    } else {
73
      for (VariableLine line : variables) {
×
74
        printEnvLine(line);
×
75
      }
×
76
    }
77
  }
1✔
78

79
  private void printEnvLine(VariableLine line) {
80
    String lineValue = line.getValue();
3✔
81
    lineValue = "\"" + lineValue + "\"";
3✔
82
    line = line.withValue(lineValue);
4✔
83
    this.context.info(line.toString());
5✔
84
  }
1✔
85
}
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

© 2026 Coveralls, Inc