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

devonfw / IDEasy / 22241505980

20 Feb 2026 09:16PM UTC coverage: 70.656% (+0.2%) from 70.474%
22241505980

Pull #1710

github

web-flow
Merge 04e4bdacd into 379acdc9d
Pull Request #1710: #404: allow logging via SLF4J

4121 of 6440 branches covered (63.99%)

Branch coverage included in aggregate %.

10704 of 14542 relevant lines covered (73.61%)

3.13 hits per line

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

85.96
cli/src/main/java/com/devonfw/tools/ide/commandlet/ContextCommandlet.java
1
package com.devonfw.tools.ide.commandlet;
2

3
import com.devonfw.tools.ide.context.AbstractIdeContext;
4
import com.devonfw.tools.ide.context.IdeContext;
5
import com.devonfw.tools.ide.context.IdeStartContextImpl;
6
import com.devonfw.tools.ide.log.IdeLogLevel;
7
import com.devonfw.tools.ide.log.IdeLogListenerBuffer;
8
import com.devonfw.tools.ide.log.IdeSubLoggerOut;
9
import com.devonfw.tools.ide.property.FlagProperty;
10
import com.devonfw.tools.ide.property.LocaleProperty;
11

12
/**
13
 * An internal pseudo-commandlet to create the {@link IdeContext}. It shall not be registered in {@link CommandletManager}.
14
 */
15
public class ContextCommandlet extends Commandlet {
1✔
16

17
  private final FlagProperty batch;
18

19
  private final FlagProperty force;
20

21
  private final FlagProperty trace;
22

23
  private final FlagProperty debug;
24

25
  private final FlagProperty quiet;
26

27
  private final FlagProperty offline;
28

29
  private final FlagProperty privacy;
30

31
  private final FlagProperty skipUpdates;
32

33
  private final FlagProperty noColors;
34

35
  private final LocaleProperty locale;
36

37
  private IdeStartContextImpl startContext;
38

39
  /**
40
   * The constructor.
41
   */
42
  public ContextCommandlet() {
43
    this(null);
3✔
44
  }
1✔
45

46
  /**
47
   * The constructor.
48
   */
49
  public ContextCommandlet(IdeStartContextImpl startContext) {
50

51
    super(null);
3✔
52
    this.startContext = startContext;
3✔
53
    this.batch = add(new FlagProperty("--batch", false, "-b"));
11✔
54
    this.force = add(new FlagProperty("--force", false, "-f"));
11✔
55
    this.trace = add(new FlagProperty("--trace", false, "-t"));
11✔
56
    this.debug = add(new FlagProperty("--debug", false, "-d"));
11✔
57
    this.quiet = add(new FlagProperty("--quiet", false, "-q"));
11✔
58
    this.privacy = add(new FlagProperty("--privacy", false, "-p"));
11✔
59
    this.offline = add(new FlagProperty("--offline", false, "-o"));
11✔
60
    this.skipUpdates = add(new FlagProperty("--skip-updates", false));
10✔
61
    this.noColors = add(new FlagProperty("--no-colors", false));
10✔
62
    this.locale = add(new LocaleProperty("--locale", false, null));
11✔
63
  }
1✔
64

65
  @Override
66
  public String getName() {
67

68
    return "context";
2✔
69
  }
70

71
  @Override
72
  public boolean isIdeHomeRequired() {
73

74
    return false;
2✔
75
  }
76

77
  @Override
78
  protected boolean isActivateJaveUtilLogging() {
79

80
    return false;
2✔
81
  }
82

83
  @Override
84
  protected void doRun() {
85

86
    IdeLogLevel logLevel = determineLogLevel();
3✔
87
    if (this.startContext == null) {
3✔
88
      IdeLogListenerBuffer listener = new IdeLogListenerBuffer();
4✔
89
      this.startContext = new IdeStartContextImpl(logLevel, level -> new IdeSubLoggerOut(level, null, true, logLevel, listener));
18✔
90
    } else if (this.context != null) {
4!
91
      IdeStartContextImpl newStartContext = ((AbstractIdeContext) this.context).getStartContext();
×
92
      assert (this.startContext == newStartContext); // fast fail during development via assert
×
93
      this.startContext = newStartContext;
×
94
    }
95
    this.startContext.setBatchMode(this.batch.isTrue());
6✔
96
    this.startContext.setForceMode(this.force.isTrue());
6✔
97
    this.startContext.setQuietMode(this.quiet.isTrue());
6✔
98
    this.startContext.setOfflineMode(this.offline.isTrue());
6✔
99
    this.startContext.setPrivacyMode(this.privacy.isTrue());
6✔
100
    this.startContext.setSkipUpdatesMode(this.skipUpdates.isTrue());
6✔
101
    this.startContext.setNoColorsMode(this.noColors.isTrue());
6✔
102
    this.startContext.setLocale(this.locale.getValue());
7✔
103
  }
1✔
104

105
  private IdeLogLevel determineLogLevel() {
106
    IdeLogLevel logLevel = IdeLogLevel.INFO;
2✔
107
    if (this.trace.isTrue()) {
4!
108
      logLevel = IdeLogLevel.TRACE;
×
109
    } else if (this.debug.isTrue()) {
4✔
110
      logLevel = IdeLogLevel.DEBUG;
3✔
111
    } else if (this.quiet.isTrue()) {
4✔
112
      logLevel = IdeLogLevel.WARNING;
2✔
113
    }
114
    return logLevel;
2✔
115
  }
116

117
  /**
118
   * @return the {@link IdeStartContextImpl} that has been created by {@link #run()}.
119
   */
120
  public IdeStartContextImpl getStartContext() {
121

122
    return this.startContext;
3✔
123
  }
124
}
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