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

devonfw / IDEasy / 22284264868

22 Feb 2026 08:00PM UTC coverage: 70.75% (+0.3%) from 70.474%
22284264868

Pull #1714

github

web-flow
Merge 98f01421f into 379acdc9d
Pull Request #1714: #404: #1713: advanced logging

4063 of 6346 branches covered (64.02%)

Branch coverage included in aggregate %.

10636 of 14430 relevant lines covered (73.71%)

3.1 hits per line

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

84.21
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.property.FlagProperty;
9
import com.devonfw.tools.ide.property.LocaleProperty;
10

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

16
  private final FlagProperty batch;
17

18
  private final FlagProperty force;
19

20
  private final FlagProperty trace;
21

22
  private final FlagProperty debug;
23

24
  private final FlagProperty quiet;
25

26
  private final FlagProperty offline;
27

28
  private final FlagProperty privacy;
29

30
  private final FlagProperty skipUpdates;
31

32
  private final FlagProperty noColors;
33

34
  private final LocaleProperty locale;
35

36
  private IdeStartContextImpl startContext;
37

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

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

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

64
  @Override
65
  public String getName() {
66

67
    return "context";
2✔
68
  }
69

70
  @Override
71
  public boolean isIdeHomeRequired() {
72

73
    return false;
2✔
74
  }
75

76
  @Override
77
  public boolean isWriteLogFile() {
78

79
    return false;
×
80
  }
81

82
  @Override
83
  protected void doRun() {
84

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

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

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

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