From b4a19bf5c1108370648a2f2bc8975c584e9c2494 Mon Sep 17 00:00:00 2001 From: Ali Shariati Najafabadi Date: Fri, 7 Aug 2026 07:18:29 +0200 Subject: [PATCH 1/2] #821: make ide prefix editable in ide shell to allow non-ide commands --- CHANGELOG.adoc | 1 + .../tools/ide/commandlet/ShellCommandlet.java | 27 +++++++++-- .../ide/commandlet/ShellCommandletTest.java | 47 +++++++++++++++++++ 3 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 cli/src/test/java/com/devonfw/tools/ide/commandlet/ShellCommandletTest.java diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 5932a42dce..0a3c55a5eb 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -20,6 +20,7 @@ Release with new features and bugfixes: * https://github.com/devonfw/IDEAsy/issues/2181[#2181]: Merged the VsCode and VsCodium plugin folder and added excluded-editions as an option for plugins * https://github.com/devonfw/IDEasy/issues/2145[#2145]: Improve documentation on symlink regarding ide ln * https://github.com/devonfw/IDEasy/issues/2235[#2235]: Language flag in cli dosn't take effect in some terminals +* https://github.com/devonfw/IDEasy/issues/821[#821]: Made the `ide` prefix in `ide shell` part of the editable input so it can be removed for non-IDEasy commands The full list of changes for this release can be found in https://github.com/devonfw/IDEasy/milestone/48?closed=1[milestone 2026.08.001]. diff --git a/cli/src/main/java/com/devonfw/tools/ide/commandlet/ShellCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/commandlet/ShellCommandlet.java index 7172588ba1..01e9305419 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/commandlet/ShellCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/commandlet/ShellCommandlet.java @@ -42,6 +42,8 @@ public final class ShellCommandlet extends Commandlet { private static final String EXIT_COMMAND = "exit"; + private static final String IDE_PREFIX = "ide "; + /** * The constructor. * @@ -90,9 +92,9 @@ protected void doRun() { while (true) { try { String cwdPath = String.valueOf(context.getCwd()); - String prompt = cwdPath + (cwdPath.length() <= 80 ? "" : System.lineSeparator()) + "$ ide "; - line = reader.readLine(prompt, rightPrompt, (MaskingCallback) null, null); - line = line.trim(); + String prompt = cwdPath + (cwdPath.length() <= 80 ? "" : System.lineSeparator()) + "$ "; + line = reader.readLine(prompt, rightPrompt, (MaskingCallback) null, IDE_PREFIX); + line = normalizeLine(line); if (EXIT_COMMAND.equals(line)) { return; } @@ -122,6 +124,25 @@ protected void doRun() { } } + /** + * Strips the pre-filled {@link #IDE_PREFIX} from the given raw input line, so that a command entered after leaving the prefix untouched (e.g. + * {@code ide status}) behaves the same as if only {@code status} was entered. This allows the user to remove the prefix via backspace to enter a + * non-IDEasy command (e.g. {@code cd}) without the misleading {@code ide} prefix. + * + * @param rawLine the raw line as read from the {@link LineReader}. + * @return the normalized line ready to be passed to {@link #runCommand(String)}. + */ + static String normalizeLine(String rawLine) { + + String line = rawLine.trim(); + if (line.equals(IDE_PREFIX.trim())) { + return ""; + } else if (line.startsWith(IDE_PREFIX)) { + return line.substring(IDE_PREFIX.length()).trim(); + } + return line; + } + /** * Converts String of arguments to array and runs the command * diff --git a/cli/src/test/java/com/devonfw/tools/ide/commandlet/ShellCommandletTest.java b/cli/src/test/java/com/devonfw/tools/ide/commandlet/ShellCommandletTest.java new file mode 100644 index 0000000000..23eb896c8b --- /dev/null +++ b/cli/src/test/java/com/devonfw/tools/ide/commandlet/ShellCommandletTest.java @@ -0,0 +1,47 @@ +package com.devonfw.tools.ide.commandlet; + +import org.junit.jupiter.api.Test; + +import com.devonfw.tools.ide.context.AbstractIdeContextTest; + +/** + * Test of {@link ShellCommandlet}. + */ +class ShellCommandletTest extends AbstractIdeContextTest { + + /** + * Test of {@link ShellCommandlet#normalizeLine(String)} when the pre-filled {@code ide } prefix is left untouched, so the command behaves the same as + * before this prefix was made part of the editable input line. + */ + @Test + void testNormalizeLineKeepsPrefixedCommand() { + + // act & assert + assertThat(ShellCommandlet.normalizeLine("ide status")).isEqualTo("status"); + assertThat(ShellCommandlet.normalizeLine("ide install java")).isEqualTo("install java"); + } + + /** + * Test of {@link ShellCommandlet#normalizeLine(String)} when the user removed the pre-filled {@code ide } prefix via backspace to enter a non-IDEasy + * command, e.g. {@code cd}, see #821 for reference. + */ + @Test + void testNormalizeLineWithRemovedPrefix() { + + // act & assert + assertThat(ShellCommandlet.normalizeLine("cd ..")).isEqualTo("cd .."); + assertThat(ShellCommandlet.normalizeLine("exit")).isEqualTo("exit"); + } + + /** + * Test of {@link ShellCommandlet#normalizeLine(String)} when the user leaves an empty or unmodified prompt. + */ + @Test + void testNormalizeLineWithEmptyInput() { + + // act & assert + assertThat(ShellCommandlet.normalizeLine("ide")).isEmpty(); + assertThat(ShellCommandlet.normalizeLine("ide ")).isEmpty(); + assertThat(ShellCommandlet.normalizeLine("")).isEmpty(); + } +} From c0372030096622375a9bd1085ba3da3ae93d59a5 Mon Sep 17 00:00:00 2001 From: Malte Brunnlieb Date: Sun, 16 Aug 2026 20:18:45 +0200 Subject: [PATCH 2/2] #821: move changelog entry to current milestone section --- CHANGELOG.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index dff9c0080d..9c783e3bdb 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -6,6 +6,7 @@ This file documents all notable changes to https://github.com/devonfw/IDEasy[IDE Release with new features and bugfixes: +* https://github.com/devonfw/IDEasy/issues/821[#821]: Made the `ide` prefix in `ide shell` part of the editable input so it can be removed for non-IDEasy commands The full list of changes for this release can be found in https://github.com/devonfw/IDEasy/milestone/49?closed=1[milestone 2026.08.002]. @@ -38,7 +39,6 @@ Release with new features and bugfixes: * https://github.com/devonfw/IDEAsy/issues/2181[#2181]: Merged the VsCode and VsCodium plugin folder and added excluded-editions as an option for plugins * https://github.com/devonfw/IDEasy/issues/2145[#2145]: Improve documentation on symlink regarding ide ln * https://github.com/devonfw/IDEasy/issues/2235[#2235]: Language flag in cli dosn't take effect in some terminals -* https://github.com/devonfw/IDEasy/issues/821[#821]: Made the `ide` prefix in `ide shell` part of the editable input so it can be removed for non-IDEasy commands * https://github.com/devonfw/IDEasy/issues/2264[#2264]: ide «tool» does not set the environment variables of the other installed tools * https://github.com/devonfw/IDEasy/issues/2136[#2136]: Add Support for Ruby URL Updater for Linux and macOS * https://github.com/devonfw/IDEasy/issues/2292[#2292]: Questions appear twice