From de6a6177e72fa6dc11d91ed9f7ab0a81425c966f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Hohwiller?= Date: Mon, 9 Oct 2023 15:27:23 +0200 Subject: [PATCH] #5: cli fixes (#74) --- cli/src/main/java/com/devonfw/tools/ide/cli/Ide.java | 6 ++++-- .../com/devonfw/tools/ide/commandlet/HelpCommandlet.java | 4 ++-- .../main/java/com/devonfw/tools/ide/property/Property.java | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cli/src/main/java/com/devonfw/tools/ide/cli/Ide.java b/cli/src/main/java/com/devonfw/tools/ide/cli/Ide.java index 507eec92d..df6e040c4 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/cli/Ide.java +++ b/cli/src/main/java/com/devonfw/tools/ide/cli/Ide.java @@ -195,7 +195,7 @@ private boolean apply(CliArgument argument, Commandlet commandlet) { endOpts = true; } else { String arg = currentArgument.get(); - this.context.trace("Trying to match argument '{}'", argument); + this.context.trace("Trying to match argument '{}'", currentArgument); if ((currentProperty != null) && (currentProperty.isExpectValue())) { currentProperty.setValueAsString(arg); if (!currentProperty.isMultiValued()) { @@ -239,7 +239,9 @@ private boolean apply(CliArgument argument, Commandlet commandlet) { return false; } } - currentProperty = null; + if ((currentProperty != null) && !currentProperty.isMultiValued()) { + currentProperty = null; + } } else { this.context.trace("Found option by name"); String value = currentArgument.getValue(); diff --git a/cli/src/main/java/com/devonfw/tools/ide/commandlet/HelpCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/commandlet/HelpCommandlet.java index 284165f28..a3c3514c2 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/commandlet/HelpCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/commandlet/HelpCommandlet.java @@ -98,12 +98,12 @@ private void printCommandletHelp(NlsBundle bundle, Commandlet cmd) { } String name = property.getName(); if (name.isEmpty()) { - assert (property instanceof KeywordProperty); + assert !(property instanceof KeywordProperty); String key = "<" + property.getAlias() + ">"; usage.append(key); values.add(key, bundle.get(cmd, property)); } else { - assert !(property instanceof KeywordProperty); + assert (property instanceof KeywordProperty); usage.append(name); } if (property.isMultiValued()) { diff --git a/cli/src/main/java/com/devonfw/tools/ide/property/Property.java b/cli/src/main/java/com/devonfw/tools/ide/property/Property.java index 594d1e4b8..7a6dc2d06 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/property/Property.java +++ b/cli/src/main/java/com/devonfw/tools/ide/property/Property.java @@ -93,7 +93,7 @@ public boolean isRequired() { */ public boolean isExpectValue() { - return !"".equals(this.name); + return "".equals(this.name); } /**