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

devonfw / IDEasy / 12353789535

16 Dec 2024 01:35PM UTC coverage: 67.478% (+0.02%) from 67.459%
12353789535

Pull #899

github

web-flow
Merge 7290dec26 into 52afdd7c7
Pull Request #899: #834: bugfix for long options of commandlets

2573 of 4154 branches covered (61.94%)

Branch coverage included in aggregate %.

6656 of 9523 relevant lines covered (69.89%)

3.07 hits per line

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

92.86
cli/src/main/java/com/devonfw/tools/ide/property/KeywordProperty.java
1
package com.devonfw.tools.ide.property;
2

3
import com.devonfw.tools.ide.cli.CliArguments;
4
import com.devonfw.tools.ide.commandlet.Commandlet;
5
import com.devonfw.tools.ide.completion.CompletionCandidateCollector;
6
import com.devonfw.tools.ide.context.IdeContext;
7

8
/**
9
 * {@link BooleanProperty} for a keyword (e.g. "install" in "ide install mvn 3.9.4").
10
 */
11
public class KeywordProperty extends BooleanProperty {
1✔
12

13
  private final String optionName;
14

15
  /**
16
   * The constructor.
17
   *
18
   * @param name the {@link #getName() property name}.
19
   * @param required the {@link #isRequired() required flag}.
20
   * @param alias the {@link #getAlias() property alias}.
21
   */
22
  public KeywordProperty(String name, boolean required, String alias) {
23

24
    super(getNormalizedName(name), required, alias);
6✔
25
    this.optionName = name;
3✔
26
  }
1✔
27

28
  private static String getNormalizedName(String name) {
29

30
    assert !name.isEmpty();
4!
31
    if (name.startsWith("--")) {
4✔
32
      return name.substring(2);
4✔
33
    }
34
    return name;
2✔
35
  }
36

37
  /**
38
   * @return the option name (e.g. "--help") or the {@link #getName() name} if not an option (e.g. "install").
39
   */
40
  public String getOptionName() {
41

42
    return this.optionName;
3✔
43
  }
44

45
  @Override
46
  public boolean isValue() {
47

48
    return true;
2✔
49
  }
50

51
  @Override
52
  public boolean isExpectValue() {
53

54
    return false;
×
55
  }
56

57
  @Override
58
  public boolean matches(String nameOrAlias) {
59

60
    if (super.matches(nameOrAlias)) {
4✔
61
      return true;
2✔
62
    }
63
    return this.optionName.equals(nameOrAlias);
5✔
64
  }
65

66
  @Override
67
  public boolean apply(CliArguments args, IdeContext context, Commandlet commandlet, CompletionCandidateCollector collector) {
68

69
    String normalizedName = this.name;
3✔
70
    if (args.current().isOption()) {
4✔
71
      normalizedName = this.optionName;
3✔
72
    }
73
    return apply(normalizedName, args, context, commandlet, collector);
8✔
74
  }
75

76
  @Override
77
  protected boolean applyValue(String argValue, boolean lookahead, CliArguments args, IdeContext context, Commandlet commandlet,
78
      CompletionCandidateCollector collector) {
79

80
    setValue(true);
3✔
81
    return true;
2✔
82
  }
83
}
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