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

devonfw / IDEasy / 17730250095

15 Sep 2025 10:38AM UTC coverage: 68.686% (+0.01%) from 68.674%
17730250095

push

github

web-flow
#1460: added --no-colors option to disable colored logging and fixed wix logging (#1483)

3401 of 5419 branches covered (62.76%)

Branch coverage included in aggregate %.

8880 of 12461 relevant lines covered (71.26%)

3.13 hits per line

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

81.13
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

44
    super(null);
3✔
45
    this.batch = add(new FlagProperty("--batch", false, "-b"));
11✔
46
    this.force = add(new FlagProperty("--force", false, "-f"));
11✔
47
    this.trace = add(new FlagProperty("--trace", false, "-t"));
11✔
48
    this.debug = add(new FlagProperty("--debug", false, "-d"));
11✔
49
    this.quiet = add(new FlagProperty("--quiet", false, "-q"));
11✔
50
    this.privacy = add(new FlagProperty("--privacy", false, "-p"));
11✔
51
    this.offline = add(new FlagProperty("--offline", false, "-o"));
11✔
52
    this.skipUpdates = add(new FlagProperty("--skip-updates", false));
10✔
53
    this.noColors = add(new FlagProperty("--no-colors", false));
10✔
54
    this.locale = add(new LocaleProperty("--locale", false, null));
11✔
55
  }
1✔
56

57
  @Override
58
  public String getName() {
59

60
    return "context";
2✔
61
  }
62

63
  @Override
64
  public boolean isIdeHomeRequired() {
65

66
    return false;
2✔
67
  }
68

69
  @Override
70
  public void run() {
71

72
    IdeLogLevel logLevel = determineLogLevel();
3✔
73
    if (this.startContext == null) {
3!
74
      IdeLogListenerBuffer listener = new IdeLogListenerBuffer();
4✔
75
      this.startContext = new IdeStartContextImpl(logLevel, level -> new IdeSubLoggerOut(level, null, true, logLevel, listener));
18✔
76
    } else if (this.context != null) {
1!
77
      IdeStartContextImpl newStartContext = ((AbstractIdeContext) this.context).getStartContext();
×
78
      assert (this.startContext == newStartContext); // fast fail during development via assert
×
79
      this.startContext = newStartContext;
×
80
    }
81
    this.startContext.setBatchMode(this.batch.isTrue());
6✔
82
    this.startContext.setForceMode(this.force.isTrue());
6✔
83
    this.startContext.setQuietMode(this.quiet.isTrue());
6✔
84
    this.startContext.setOfflineMode(this.offline.isTrue());
6✔
85
    this.startContext.setPrivacyMode(this.privacy.isTrue());
6✔
86
    this.startContext.setSkipUpdatesMode(this.skipUpdates.isTrue());
6✔
87
    this.startContext.setNoColorsMode(this.noColors.isTrue());
6✔
88
    this.startContext.setLocale(this.locale.getValue());
7✔
89
  }
1✔
90

91
  private IdeLogLevel determineLogLevel() {
92
    IdeLogLevel logLevel = IdeLogLevel.INFO;
2✔
93
    if (this.trace.isTrue()) {
4!
94
      logLevel = IdeLogLevel.TRACE;
×
95
    } else if (this.debug.isTrue()) {
4✔
96
      logLevel = IdeLogLevel.DEBUG;
3✔
97
    } else if (this.quiet.isTrue()) {
4✔
98
      logLevel = IdeLogLevel.WARNING;
2✔
99
    }
100
    return logLevel;
2✔
101
  }
102

103
  /**
104
   * @return the {@link IdeStartContextImpl} that has been created by {@link #run()}.
105
   */
106
  public IdeStartContextImpl getStartContext() {
107

108
    return this.startContext;
3✔
109
  }
110
}
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