Skip to content

#1457: Improve CLI error messages with suggestions#1858

Open
KarimALotfy wants to merge 11 commits into
devonfw:mainfrom
KarimALotfy:feature/1457-improve-CLI-error-messages-on-invalid-args-or-commandlets
Open

#1457: Improve CLI error messages with suggestions#1858
KarimALotfy wants to merge 11 commits into
devonfw:mainfrom
KarimALotfy:feature/1457-improve-CLI-error-messages-on-invalid-args-or-commandlets

Conversation

@KarimALotfy
Copy link
Copy Markdown
Contributor

@KarimALotfy KarimALotfy commented Apr 27, 2026

Improve CLI error messages with suggestions

This PR fixes #1457

Implemented changes:

  • Add clearer messages when a command requires IDEasy project context.
  • Detect unknown options or invalid arguments and values, and suggest the closest valid option (Did you mean ...).
  • Suggest closest commandlet name for unknown commands.
  • Suggesting available installation versions, when the entered version cannot be matched
    (Reused from PR : "#1643 improve ux on syntax error #1856" of improve UX on CLI syntax error #1643 by @satorus )
  • Add tests for the new suggestion flows

Checklist for this PR

Make sure everything is checked before merging this PR. For further info please also see
our DoD.

  • When running mvn clean test locally all tests pass and build is successful
  • PR title is of the form #«issue-id»: «brief summary» (e.g. #921: fixed setup.bat). If no issue ID exists, title only.
  • PR top-level comment summarizes what has been done and contains link to addressed issue(s)
  • PR and issue(s) have suitable labels
  • Issue is set to In Progress and assigned to you or there is no issue (might happen for very small PRs)
  • You followed all coding conventions
  • You have added the issue implemented by your PR in CHANGELOG.adoc unless issue is labeled
    with internal

- Add clearer messages when a command requires IDEasy project context.
- Detect unknown options and suggest the closest valid option (Did you mean ...).
- Suggest closest commandlet name for unknown commands.
- Add tests for the new suggestion flows
@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Apr 27, 2026

Coverage Report for CI Build 26276726360

Coverage increased (+0.1%) to 71.188%

Details

  • Coverage increased (+0.1%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 238 coverage regressions across 5 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

238 previously-covered lines in 5 files lost coverage.

File Lines Losing Coverage Coverage
com/devonfw/tools/ide/context/AbstractIdeContext.java 176 66.83%
com/devonfw/tools/ide/property/Property.java 33 72.59%
com/devonfw/tools/ide/version/VersionIdentifier.java 23 81.12%
com/devonfw/tools/ide/validation/ValidationState.java 5 85.96%
com/devonfw/tools/ide/version/VersionSegment.java 1 89.76%

Coverage Stats

Coverage Status
Relevant Lines: 15727
Covered Lines: 11677
Line Coverage: 74.25%
Relevant Branches: 7104
Covered Branches: 4576
Branch Coverage: 64.41%
Branches in Coverage %: Yes
Coverage Strength: 3.15 hits per line

💛 - Coveralls

@KarimALotfy KarimALotfy self-assigned this Apr 27, 2026
@KarimALotfy KarimALotfy moved this from 🆕 New to Team Review in IDEasy board Apr 27, 2026
@satorus satorus mentioned this pull request Apr 28, 2026
15 tasks
@KarimALotfy KarimALotfy moved this from Team Review to 🏗 In progress in IDEasy board Apr 30, 2026
 -Added Error handling for Invalid Arguments
-Added in ClI Error the installable Versions as a suggestion when an unfound version is entered
…-or-commandlets' of https://github.com/KarimALotfy/IDEasy into feature/1457-improve-CLI-error-messages-on-invalid-args-or-commandlets
@KarimALotfy KarimALotfy moved this from 🏗 In progress to Team Review in IDEasy board Apr 30, 2026
@KarimALotfy KarimALotfy added enhancement New feature or request CLI IDEasy command-line-interface (parsing args, etc.) labels Apr 30, 2026
Copy link
Copy Markdown
Contributor

@MarvMa MarvMa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice Work! This will help users in the future to understand incorrect inputs better and even get a recommendation. I tested the functionality on Windows using the following tests:

  • delete settings file -> run ide update -> the expected warning is beeing printed
  • run ide udpate -> a suggestion is beeing printed

I left some comments regarding the naming of boolean methods and a comment on a nested if else clause. Except that everything looks fine to me 🚀

Comment thread cli/src/main/java/com/devonfw/tools/ide/cli/CliSuggester.java
Comment thread cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java Outdated
Comment thread CHANGELOG.adoc Outdated
- Refactored methods in CliSuggester to match  coding-conventions
- Improved readability in run method in AbstractIdeContext by reducing nested code
- Change in CHANGELOG.adoc
@KarimALotfy KarimALotfy moved this from Team Review to 👀 In review in IDEasy board May 8, 2026
@KarimALotfy KarimALotfy moved this from 👀 In review to Team Review in IDEasy board May 8, 2026
@KarimALotfy KarimALotfy moved this from Team Review to 👀 In review in IDEasy board May 11, 2026
Copy link
Copy Markdown
Contributor

@MarvMa MarvMa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really clean, Nice Job 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLI IDEasy command-line-interface (parsing args, etc.) enhancement New feature or request

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

Improve CLI error messages on invalid args or commandlets not available in current context

3 participants