Skip to content

Commit

Permalink
#739: removed "not inside an IDE installation message" (#753)
Browse files Browse the repository at this point in the history
  • Loading branch information
leonrohne27 authored Nov 29, 2024
1 parent 9ad21db commit d7df00d
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Release with new features and bugfixes:
* https://github.com/devonfw/IDEasy/issues/737[#737]: Adds cd command to ide shell
* https://github.com/devonfw/IDEasy/issues/758[#758]: Create status commandlet
* https://github.com/devonfw/IDEasy/issues/754[#754]: Again messages break processable command output
* https://github.com/devonfw/IDEasy/issues/737[#739]: Improved error handling to show 'You are not inside an IDE installation' only when relevant.

The full list of changes for this release can be found in https://github.com/devonfw/IDEasy/milestone/16?closed=1[milestone 2024.12.001].

Expand Down
17 changes: 17 additions & 0 deletions cli/src/main/java/com/devonfw/tools/ide/cli/CliExitException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.devonfw.tools.ide.cli;

import com.devonfw.tools.ide.process.ProcessResult;

/**
* {@link CliException} Empty exception that is thrown when a required variable is not set.
*/
public class CliExitException extends CliException {

/**
* The constructor.
*/
public CliExitException() {

super("", ProcessResult.EXIT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Map;
import java.util.stream.Collectors;

import com.devonfw.tools.ide.cli.CliExitException;
import com.devonfw.tools.ide.context.AbstractIdeContext;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.environment.EnvironmentVariablesType;
Expand Down Expand Up @@ -42,7 +43,7 @@ public String getName() {
@Override
public boolean isIdeHomeRequired() {

return true;
return false;
}

@Override
Expand All @@ -53,7 +54,9 @@ public boolean isProcessableOutput() {

@Override
public void run() {

if (context.getIdeHome() == null) {
throw new CliExitException();
}
boolean winCmd = false;
WindowsPathSyntax pathSyntax = null;
IdeSubLogger logger = this.context.level(IdeLogLevel.PROCESSABLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,17 +277,6 @@ private String getMessageIdeRootNotFound() {
}
}

/**
* @return the status message about the {@link #getIdeHome() IDE_HOME} detection and environment variable initialization.
*/
public String getMessageIdeHome() {

if (this.ideHome == null) {
return getMessageIdeHomeNotFound();
}
return getMessageIdeHomeFound();
}

/**
* @return {@code true} if this is a test context for JUnits, {@code false} otherwise.
*/
Expand All @@ -301,6 +290,7 @@ protected SystemPath computeSystemPath() {
return new SystemPath(this);
}


private boolean isIdeHome(Path dir) {

if (!Files.isDirectory(dir.resolve("workspaces"))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public interface ProcessResult {
/** Return code if tool was requested that is not installed. */
int TOOL_NOT_INSTALLED = 4;

/** Return code to exit if condition not met */
int EXIT = 17;

/**
* Return code to abort gracefully.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import com.devonfw.tools.ide.context.AbstractIdeContextTest;
import com.devonfw.tools.ide.context.IdeTestContext;
import com.devonfw.tools.ide.context.IdeTestContextMock;
import com.devonfw.tools.ide.log.IdeLogEntry;
import com.devonfw.tools.ide.log.IdeLogLevel;
import com.devonfw.tools.ide.os.SystemInfoMock;
Expand Down Expand Up @@ -127,18 +126,6 @@ public void testRunInfoLogging() {
);
}

/**
* Test that {@link EnvironmentCommandlet} requires home.
*/
@Test
public void testThatHomeIsRequired() {

// arrange
EnvironmentCommandlet env = new EnvironmentCommandlet(IdeTestContextMock.get());
// act & assert
assertThat(env.isIdeHomeRequired()).isTrue();
}

private String normalize(Path path) {

return path.toString().replace('\\', '/');
Expand Down

0 comments on commit d7df00d

Please sign in to comment.