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

devonfw / IDEasy / 15142420580

20 May 2025 04:04PM UTC coverage: 67.846% (+0.2%) from 67.695%
15142420580

Pull #1318

github

web-flow
Merge 44f97aa8f into 0062654bb
Pull Request #1318: #1314: add IdeContext.runWithoutLogging to temporary disable logging

3114 of 4996 branches covered (62.33%)

Branch coverage included in aggregate %.

8012 of 11403 relevant lines covered (70.26%)

3.07 hits per line

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

77.08
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 skipUpdates;
30

31
  private final LocaleProperty locale;
32

33
  private IdeStartContextImpl startContext;
34

35
  /**
36
   * The constructor.
37
   */
38
  public ContextCommandlet() {
39

40
    super(null);
3✔
41
    this.batch = add(new FlagProperty("--batch", false, "-b"));
11✔
42
    this.force = add(new FlagProperty("--force", false, "-f"));
11✔
43
    this.trace = add(new FlagProperty("--trace", false, "-t"));
11✔
44
    this.debug = add(new FlagProperty("--debug", false, "-d"));
11✔
45
    this.quiet = add(new FlagProperty("--quiet", false, "-q"));
11✔
46
    this.offline = add(new FlagProperty("--offline", false, "-o"));
11✔
47
    this.skipUpdates = add(new FlagProperty("--skip-updates", false));
10✔
48
    this.locale = add(new LocaleProperty("--locale", false, null));
11✔
49
  }
1✔
50

51
  @Override
52
  public String getName() {
53

54
    return "context";
2✔
55
  }
56

57
  @Override
58
  public boolean isIdeHomeRequired() {
59

60
    return false;
2✔
61
  }
62

63
  @Override
64
  public void run() {
65

66
    IdeLogLevel logLevel = determineLogLevel();
3✔
67
    if (this.startContext == null) {
3!
68
      this.startContext = new IdeStartContextImpl(logLevel, level -> new IdeSubLoggerOut(level, null, true, logLevel, new IdeLogListenerBuffer()));
20✔
69
    } else if (this.context != null) {
×
70
      IdeStartContextImpl newStartContext = ((AbstractIdeContext) this.context).getStartContext();
×
71
      assert (this.startContext == newStartContext); // fast fail during development via assert
×
72
      this.startContext = newStartContext;
×
73
    }
74
    this.startContext.setBatchMode(this.batch.isTrue());
6✔
75
    this.startContext.setForceMode(this.force.isTrue());
6✔
76
    this.startContext.setQuietMode(this.quiet.isTrue());
6✔
77
    this.startContext.setOfflineMode(this.offline.isTrue());
6✔
78
    this.startContext.setSkipUpdatesMode(this.skipUpdates.isTrue());
6✔
79
    this.startContext.setLocale(this.locale.getValue());
7✔
80
  }
1✔
81

82
  private IdeLogLevel determineLogLevel() {
83
    IdeLogLevel logLevel = IdeLogLevel.INFO;
2✔
84
    if (this.trace.isTrue()) {
4!
85
      logLevel = IdeLogLevel.TRACE;
×
86
    } else if (this.debug.isTrue()) {
4✔
87
      logLevel = IdeLogLevel.DEBUG;
3✔
88
    } else if (this.quiet.isTrue()) {
4✔
89
      logLevel = IdeLogLevel.WARNING;
2✔
90
    }
91
    return logLevel;
2✔
92
  }
93

94
  /**
95
   * @return the {@link IdeStartContextImpl} that has been created by {@link #run()}.
96
   */
97
  public IdeStartContextImpl getStartContext() {
98

99
    return this.startContext;
3✔
100
  }
101
}
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