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

devonfw / IDEasy / 12236799868

09 Dec 2024 01:37PM UTC coverage: 67.035% (+0.08%) from 66.953%
12236799868

push

github

web-flow
#799: fix zip extraction to preserve file attributes (#835)

2543 of 4142 branches covered (61.4%)

Branch coverage included in aggregate %.

6608 of 9509 relevant lines covered (69.49%)

3.06 hits per line

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

0.0
cli/src/main/java/com/devonfw/tools/ide/context/IdeContextConsole.java
1
package com.devonfw.tools.ide.context;
2

3
import java.util.Scanner;
4

5
import com.devonfw.tools.ide.io.IdeProgressBar;
6
import com.devonfw.tools.ide.io.IdeProgressBarConsole;
7
import com.devonfw.tools.ide.log.IdeLogLevel;
8
import com.devonfw.tools.ide.log.IdeSubLoggerOut;
9

10
/**
11
 * Default implementation of {@link IdeContext} using the console.
12
 */
13
public class IdeContextConsole extends AbstractIdeContext {
14

15
  private final Scanner scanner;
16

17
  /**
18
   * The constructor.
19
   *
20
   * @param minLogLevel the minimum {@link IdeLogLevel} to enable. Should be {@link IdeLogLevel#INFO} by default.
21
   * @param out the {@link Appendable} to {@link Appendable#append(CharSequence) write} log messages to.
22
   * @param colored - {@code true} for colored output according to {@link IdeLogLevel}, {@code false} otherwise.
23
   */
24
  public IdeContextConsole(IdeLogLevel minLogLevel, Appendable out, boolean colored) {
25

26
    super(new IdeStartContextImpl(minLogLevel, level -> new IdeSubLoggerOut(level, out, colored, minLogLevel, null)), null);
×
27
    if (System.console() == null) {
×
28
      debug("System console not available - using System.in as fallback");
×
29
      this.scanner = new Scanner(System.in);
×
30
    } else {
31
      this.scanner = null;
×
32
    }
33
  }
×
34

35
  /**
36
   * The constructor.
37
   *
38
   * @param startContext the {@link IdeStartContextImpl}.
39
   */
40
  public IdeContextConsole(IdeStartContextImpl startContext) {
41

42
    super(startContext, null);
×
43
    if (System.console() == null) {
×
44
      debug("System console not available - using System.in as fallback");
×
45
      this.scanner = new Scanner(System.in);
×
46
    } else {
47
      this.scanner = null;
×
48
    }
49
  }
×
50

51
  @Override
52
  protected String readLine() {
53

54
    if (this.scanner == null) {
×
55
      return System.console().readLine();
×
56
    } else {
57
      return this.scanner.nextLine();
×
58
    }
59
  }
60

61
  @Override
62
  public IdeProgressBar newProgressBar(String title, long size, String unitName, long unitSize) {
63

64
    return new IdeProgressBarConsole(getSystemInfo(), title, size, unitName, unitSize);
×
65
  }
66
}
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