Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#415: log command before sudo pw #732

Merged
merged 9 commits into from
Nov 11, 2024
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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/415[#415]: Added a message that will inform the user for what process he will need to enter his sudo- password

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ protected boolean runWithPackageManager(boolean silent, String... commandStrings
*/
protected boolean runWithPackageManager(boolean silent, List<PackageManagerCommand> pmCommands) {

logPackageManagerCommands(pmCommands);
leonrohne27 marked this conversation as resolved.
Show resolved Hide resolved

for (PackageManagerCommand pmCommand : pmCommands) {
PackageManager packageManager = pmCommand.packageManager();
Path packageManagerPath = this.context.getPath().findBinary(Path.of(packageManager.getBinaryName()));
Expand All @@ -70,6 +72,19 @@ protected boolean runWithPackageManager(boolean silent, List<PackageManagerComma
return false; // None of the package manager commands were successful
}

private void logPackageManagerCommands(List<PackageManagerCommand> pmCommands) {
StringBuilder commandLog = new StringBuilder("We need to run the following privileged command(s):\n");
leonrohne27 marked this conversation as resolved.
Show resolved Hide resolved

for (PackageManagerCommand pmCommand : pmCommands) {
for (String command : pmCommand.commands()) {
commandLog.append(command).append("\n");
}
}
commandLog.append("This will require root permissions!");

this.context.info(commandLog.toString());
}

/**
* Executes the provided package manager command.
*
Expand Down
Loading