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

devonfw / IDEasy / 12243460377

09 Dec 2024 08:09PM UTC coverage: 67.098% (+0.03%) from 67.069%
12243460377

push

github

web-flow
#834 : support for --help (#876)

2554 of 4154 branches covered (61.48%)

Branch coverage included in aggregate %.

6627 of 9529 relevant lines covered (69.55%)

3.06 hits per line

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

92.59
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
  @Override
38
  public boolean isValue() {
39

40
    return true;
2✔
41
  }
42

43
  @Override
44
  public boolean isExpectValue() {
45

46
    return false;
×
47
  }
48

49
  @Override
50
  public boolean matches(String nameOrAlias) {
51

52
    if (super.matches(nameOrAlias)) {
4✔
53
      return true;
2✔
54
    }
55
    return this.optionName.equals(nameOrAlias);
5✔
56
  }
57

58
  @Override
59
  public boolean apply(CliArguments args, IdeContext context, Commandlet commandlet, CompletionCandidateCollector collector) {
60

61
    String normalizedName = this.name;
3✔
62
    if (args.current().isOption()) {
4✔
63
      normalizedName = this.optionName;
3✔
64
    }
65
    return apply(normalizedName, args, context, commandlet, collector);
8✔
66
  }
67

68
  @Override
69
  protected boolean applyValue(String argValue, boolean lookahead, CliArguments args, IdeContext context, Commandlet commandlet,
70
      CompletionCandidateCollector collector) {
71

72
    setValue(true);
3✔
73
    return true;
2✔
74
  }
75
}
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