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

devonfw / IDEasy / 9907372175

12 Jul 2024 11:49AM UTC coverage: 61.142% (-0.02%) from 61.162%
9907372175

push

github

hohwille
fixed tests

1997 of 3595 branches covered (55.55%)

Branch coverage included in aggregate %.

5296 of 8333 relevant lines covered (63.55%)

2.8 hits per line

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

81.25
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.IdeContextConsole;
6
import com.devonfw.tools.ide.log.IdeLogLevel;
7
import com.devonfw.tools.ide.property.FlagProperty;
8
import com.devonfw.tools.ide.property.LocaleProperty;
9

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

15
  private final FlagProperty batch;
16

17
  private final FlagProperty force;
18

19
  private final FlagProperty trace;
20

21
  private final FlagProperty debug;
22

23
  private final FlagProperty quiet;
24

25
  private final FlagProperty offline;
26

27
  private final LocaleProperty locale;
28

29
  private AbstractIdeContext ideContext;
30

31
  /**
32
   * The constructor.
33
   */
34
  public ContextCommandlet() {
35

36
    super(null);
3✔
37
    this.batch = add(new FlagProperty("--batch", false, "-b"));
11✔
38
    this.force = add(new FlagProperty("--force", false, "-f"));
11✔
39
    this.trace = add(new FlagProperty("--trace", false, "-t"));
11✔
40
    this.debug = add(new FlagProperty("--debug", false, "-d"));
11✔
41
    this.quiet = add(new FlagProperty("--quiet", false, "-q"));
11✔
42
    this.offline = add(new FlagProperty("--offline", false, "-o"));
11✔
43
    this.locale = add(new LocaleProperty("--locale", false, null));
11✔
44
  }
1✔
45

46
  @Override
47
  public String getName() {
48

49
    return "context";
2✔
50
  }
51

52
  @Override
53
  public boolean isIdeHomeRequired() {
54

55
    return false;
2✔
56
  }
57

58
  @Override
59
  public void run() {
60

61
    IdeLogLevel logLevel = IdeLogLevel.INFO;
2✔
62
    if (this.trace.isTrue()) {
4!
63
      logLevel = IdeLogLevel.TRACE;
×
64
    } else if (this.debug.isTrue()) {
4!
65
      logLevel = IdeLogLevel.DEBUG;
×
66
    } else if (this.quiet.isTrue()) {
4!
67
      logLevel = IdeLogLevel.WARNING;
×
68
    }
69

70
    this.ideContext = new IdeContextConsole(logLevel, null, true);
8✔
71
    this.ideContext.setBatchMode(this.batch.isTrue());
6✔
72
    this.ideContext.setForceMode(this.force.isTrue());
6✔
73
    this.ideContext.setQuietMode(this.quiet.isTrue());
6✔
74
    this.ideContext.setOfflineMode(this.offline.isTrue());
6✔
75
    this.ideContext.setLocale(this.locale.getValue());
7✔
76
  }
1✔
77

78
  /**
79
   * @return the {@link IdeContext} that has been created by {@link #run()}.
80
   */
81
  public AbstractIdeContext getIdeContext() {
82

83
    return this.ideContext;
3✔
84
  }
85
}
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