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

Allow editing of params at any time #30939

Merged
merged 1 commit into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@
import java.util.logging.Level;
import java.util.stream.Collectors;

import org.jboss.logging.Logger;
import org.jboss.logmanager.LogManager;

import io.quarkus.deployment.dev.RuntimeUpdatesProcessor;
import io.quarkus.deployment.dev.testing.MessageFormat;
import io.quarkus.deployment.dev.testing.TestSupport;
import io.quarkus.deployment.util.CommandLineUtil;
import io.quarkus.dev.console.QuarkusConsole;
import io.quarkus.dev.spi.DevModeType;

Expand Down Expand Up @@ -97,6 +100,25 @@ void installBuiltins(DevModeType devModeType) {
commands.add(new ConsoleCommand('s', "Force restart", null, () -> {
forceRestart();
}));
commands.add(new ConsoleCommand('e', "Edits the command line parameters and restarts",
"to edit command line args (currently '" + MessageFormat.GREEN
+ String.join(" ", RuntimeUpdatesProcessor.INSTANCE.getCommandLineArgs()) + MessageFormat.RESET
+ "')",
100, new ConsoleCommand.HelpState(() -> BLUE,
() -> String.join(" ", RuntimeUpdatesProcessor.INSTANCE.getCommandLineArgs())),
new Consumer<String>() {
@Override
public void accept(String args) {
try {
RuntimeUpdatesProcessor.INSTANCE.setCommandLineArgs(
CommandLineUtil.translateCommandline(args));
} catch (Exception e) {
Logger.getLogger(ConsoleStateManager.class).errorf(e, "Failed to parse command line %s", args);
return;
}
RuntimeUpdatesProcessor.INSTANCE.doScan(true, true);
}
}));

commands.add(new ConsoleCommand('i', "Toggle instrumentation based reload",
new ConsoleCommand.HelpState(() -> RuntimeUpdatesProcessor.INSTANCE.instrumentationEnabled()), () -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.quarkus.deployment.dev;

import static io.quarkus.deployment.dev.testing.MessageFormat.BLUE;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
Expand Down Expand Up @@ -42,10 +40,8 @@
import io.quarkus.deployment.builditem.ApplicationClassPredicateBuildItem;
import io.quarkus.deployment.console.ConsoleCommand;
import io.quarkus.deployment.console.ConsoleStateManager;
import io.quarkus.deployment.dev.testing.MessageFormat;
import io.quarkus.deployment.dev.testing.TestSupport;
import io.quarkus.deployment.steps.ClassTransformingBuildStep;
import io.quarkus.deployment.util.CommandLineUtil;
import io.quarkus.dev.appstate.ApplicationStartException;
import io.quarkus.dev.console.DevConsoleManager;
import io.quarkus.dev.spi.DeploymentFailedStartHandler;
Expand Down Expand Up @@ -110,27 +106,7 @@ public void accept(Integer integer) {
() -> {
consoleContext.reset();
RuntimeUpdatesProcessor.INSTANCE.doScan(true, true);
}),
new ConsoleCommand('e', "Edits the command line parameters and restarts",
"to edit command line args (currently '" + MessageFormat.GREEN
+ String.join(" ", context.getArgs()) + MessageFormat.RESET + "')",
100, new ConsoleCommand.HelpState(() -> BLUE,
() -> String.join(" ", context.getArgs())),
new Consumer<String>() {
@Override
public void accept(String args) {
try {
context.setArgs(
CommandLineUtil.translateCommandline(args));
} catch (Exception e) {
log.error("Failed to parse command line", e);
return;
}
consoleContext.reset();
RuntimeUpdatesProcessor.INSTANCE.doScan(true, true);
}
}));

}));
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1252,4 +1252,16 @@ boolean isWatchedFileRestartNeeded(String changedFile) {
}
}

public String[] getCommandLineArgs() {
String[] contextArgs = context.getArgs();
if (contextArgs == null) {
return new String[0];
}
return contextArgs;
}

public RuntimeUpdatesProcessor setCommandLineArgs(String[] commandLineArgs) {
this.context.setArgs(commandLineArgs);
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ public void close() throws Throwable {
context.setTest(true);
context.setAbortOnFailedStart(!allowFailedStart);
context.getBuildSystemProperties().put("quarkus.banner.enabled", "false");
context.getBuildSystemProperties().put("quarkus.console.disable-input", "true"); //surefire communicates via stdin, we don't want the test to be reading input
context.getBuildSystemProperties().putAll(buildSystemProperties);
devModeMain = new DevModeMain(context);
devModeMain.start();
Expand Down