Skip to content

#1457: Improve CLI error messages with suggestions - #1858

Merged
hohwille merged 17 commits into
devonfw:mainfrom
KarimALotfy:feature/1457-improve-CLI-error-messages-on-invalid-args-or-commandlets
Jun 16, 2026
Merged

#1457: Improve CLI error messages with suggestions#1858
hohwille merged 17 commits into
devonfw:mainfrom
KarimALotfy:feature/1457-improve-CLI-error-messages-on-invalid-args-or-commandlets

Conversation

@KarimALotfy

@KarimALotfy KarimALotfy commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

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

coveralls commented Apr 27, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 27607517085

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.2%) to 71.276%

Details

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

Uncovered Changes

No uncovered changes found.

Coverage Regressions

236 previously-covered lines in 4 files lost coverage.

File Lines Losing Coverage Coverage
com/devonfw/tools/ide/context/AbstractIdeContext.java 175 66.67%
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%

Coverage Stats

Coverage Status
Relevant Lines: 16222
Covered Lines: 12055
Line Coverage: 74.31%
Relevant Branches: 7250
Covered Branches: 4675
Branch Coverage: 64.48%
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

@MarvMa MarvMa left a comment

Copy link
Copy Markdown
Contributor

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

@MarvMa MarvMa left a comment

Copy link
Copy Markdown
Contributor

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 💯

@hohwille hohwille left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@KarimALotfy Wow. Thank you for your great PR. I looked at your test and immediately saw the beauty of your solution that brings great UX. Digging in your implementation I found that you used established IT algorithm (levenshtein distance) as a pattern to this problem. Awesome job 🥇
I really want to get this merged.
Sorry that I still have some review-comments and one is just a stupid question where I could not understand something. Typically, we can just resolve that thread but hopefully you can answer the question quickly to enlighten me. 😄

Comment thread cli/src/main/java/com/devonfw/tools/ide/cli/CliSuggester.java Outdated
Comment thread CHANGELOG.adoc Outdated
Comment thread cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java Outdated
Comment thread cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeContext.java Outdated
@hohwille hohwille added this to the release:2026.06.001 milestone May 29, 2026
hohwille and others added 6 commits May 29, 2026 18:43
@hohwille
hohwille merged commit ec9c73a into devonfw:main Jun 16, 2026
3 checks passed
@github-project-automation github-project-automation Bot moved this from 👀 In review to ✅ Done in IDEasy board Jun 16, 2026
@AdemZarrouki

Copy link
Copy Markdown
Contributor

tested successfully with 2026.06.001-06_17_03-SNAPSHOT on windows

$ ide -p update
The update commandlet requires an IDEasy project to work.
Please run "icd <project-name>" before calling "ide update".
Call "ide help" for additional details.

Error: IDEasy failed with exit code 1

$ cd IDEasy/workspaces/main/

$ ide upgrade --mdoe=snapshot
Option "--mdoe" not found for commandlet "upgrade"
Did you mean "--mode"?
Available options are: --mode.
Call "ide help upgrade" for additional details.

Error: IDEasy failed with exit code 1

$ ide updtea
Unknown command "updtea".
Did you mean "update"?
Call "ide help" for additional details.

Error: IDEasy failed with exit code 1

$ ide insall nest
Unknown command "insall".
Did you mean "install"?
Call "ide help" for additional details.

Error: IDEasy failed with exit code 1

@AdemZarrouki AdemZarrouki added the QA approved Label a PR that has been re-testet via nightly SNAPSHOT after merge and commented. label Jun 17, 2026
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 QA approved Label a PR that has been re-testet via nightly SNAPSHOT after merge and commented.

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

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

5 participants