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

devonfw / IDEasy / 11970498949

22 Nov 2024 10:05AM UTC coverage: 67.435% (-0.007%) from 67.442%
11970498949

push

github

web-flow
#637: Option to disable updates (#765)

2491 of 4036 branches covered (61.72%)

Branch coverage included in aggregate %.

6467 of 9248 relevant lines covered (69.93%)

3.09 hits per line

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

75.51
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
      final IdeLogListenerBuffer buffer = new IdeLogListenerBuffer();
4✔
69
      this.startContext = new IdeStartContextImpl(logLevel, level -> new IdeSubLoggerOut(level, null, true, logLevel, buffer));
18✔
70
    } else if (this.context != null) {
1!
71
      IdeStartContextImpl newStartContext = ((AbstractIdeContext) this.context).getStartContext();
×
72
      assert (this.startContext == newStartContext); // fast fail during development via assert
×
73
      this.startContext = newStartContext;
×
74
    }
75
    this.startContext.setBatchMode(this.batch.isTrue());
6✔
76
    this.startContext.setForceMode(this.force.isTrue());
6✔
77
    this.startContext.setQuietMode(this.quiet.isTrue());
6✔
78
    this.startContext.setOfflineMode(this.offline.isTrue());
6✔
79
    this.startContext.setSkipUpdatesMode(this.skipUpdates.isTrue());
6✔
80
    this.startContext.setLocale(this.locale.getValue());
7✔
81
  }
1✔
82

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

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

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

© 2025 Coveralls, Inc