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

devonfw / IDEasy / 29803149984

21 Jul 2026 05:08AM UTC coverage: 72.439% (-0.04%) from 72.476%
29803149984

Pull #2179

github

web-flow
Merge c6c1d1813 into 3221b7580
Pull Request #2179: Feature/2165 interactive template variables

4961 of 7574 branches covered (65.5%)

Branch coverage included in aggregate %.

12804 of 16950 relevant lines covered (75.54%)

3.2 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 org.slf4j.Logger;
6
import org.slf4j.LoggerFactory;
7

8
import com.devonfw.tools.ide.io.IdeProgressBar;
9
import com.devonfw.tools.ide.io.IdeProgressBarConsole;
10
import com.devonfw.tools.ide.log.IdeLogLevel;
11
import com.devonfw.tools.ide.log.IdeLogListenerNone;
12

13
/**
14
 * Default implementation of {@link IdeContext} using the console.
15
 */
16
public class IdeContextConsole extends AbstractIdeContext {
17

18
  private static final Logger LOG = LoggerFactory.getLogger(IdeContextConsole.class);
×
19

20
  private final Scanner scanner;
21

22
  /**
23
   * The constructor.
24
   */
25
  public IdeContextConsole() {
26
    this(new IdeStartContextImpl(IdeLogLevel.INFO, IdeLogListenerNone.INSTANCE));
×
27
  }
×
28

29
  /**
30
   * The constructor.
31
   *
32
   * @param startContext the {@link IdeStartContextImpl}.
33
   */
34
  public IdeContextConsole(IdeStartContextImpl startContext) {
35

36
    super(startContext, null);
×
37
    if (System.console() == null) {
×
38
      LOG.debug("System console not available - using System.in as fallback");
×
39
      this.scanner = new Scanner(System.in);
×
40
    } else {
41
      this.scanner = null;
×
42
    }
43
  }
×
44

45
  @Override
46
  protected String readLine() {
47

48
    if (this.scanner == null) {
×
49
      return System.console().readLine();
×
50
    } else {
51
      return this.scanner.nextLine();
×
52
    }
53
  }
54

55
  @Override
56
  protected String readSecretLine() {
57

58
    if (this.scanner == null) {
×
59
      char[] secret = System.console().readPassword();
×
60
      if (secret == null) {
×
61
        return "";
×
62
      }
63
      return new String(secret);
×
64
    } else {
65
      LOG.warn("System console not available - secret input will be visible while typing!");
×
66
      return this.scanner.nextLine();
×
67
    }
68
  }
69

70
  @Override
71
  public IdeProgressBar newProgressBar(String title, long size, String unitName, long unitSize) {
72

73
    return new IdeProgressBarConsole(getSystemInfo(), title, size, unitName, unitSize);
×
74
  }
75

76
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc