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

[CLI IMPROVEMENT] improved cli message for new cmd #43469

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,13 @@ public void execute() {
.build();

taskExecutor.executeTasks(project);
Path targetDirPath = project.sourceRoot().resolve("target");
String packageName = project.sourceRoot().getFileName().toString();
String jarFileName = packageName+".jar";
Path jarFilePath = targetDirPath.resolve("bin").resolve(jarFileName);
outStream.println("What's next?");
outStream.println("Execute java -jar " + jarFilePath.toString() + " to run the program");

if (this.exitWhenFinish) {
Runtime.getRuntime().exit(0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,31 @@ public void execute() {
packagePath = Paths.get(argList.get(0));
}
errStream.println("Created new package '" + packageName + "' at " + packagePath + ".");
errStream.println("What's next");
switch (template) {
case "main":
errStream.println("Execute the below command to build the executable JAR file:");
errStream.println("\t bal build " + packageName);
break;

case "service":
errStream.println("Execute the below command to run the service:");
errStream.println("\t bal run " + packageName);
errStream.println("Else, execute the below command to build the executable JAR file:");
errStream.println("\t bal build " + packageName);
break;

case "lib":
errStream.println("Execute the below command to create the Ballerina archive:");
errStream.println("\t bal pack " + packageName);
break;

default:
errStream.println("Execute the below command to run the program:");
errStream.println("\t bal run " + packageName);

break;
}
}
if (this.exitWhenFinish) {
Runtime.getRuntime().exit(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ public void execute() {
}
} catch (ProjectException e) {
CommandUtil.printError(this.errStream, e.getMessage(), null, false);

CommandUtil.exitError(this.exitWhenFinish);
return;
}
Expand Down Expand Up @@ -265,6 +266,10 @@ public void execute() {
.addTask(new DumpBuildTimeTask(outStream), !project.buildOptions().dumpBuildTime())
.build();

outStream.println("What's Next");
outStream.println("Execute the below command to publish the package to Ballerina Central.");
outStream.println("\t bal push ");

taskExecutor.executeTasks(project);
if (this.exitWhenFinish) {
Runtime.getRuntime().exit(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ public void testNewCommandInExistingDirectory() throws IOException {
""";
Assert.assertEquals(gitignoreContent.trim(), expectedGitignoreContent.trim());
Assert.assertTrue(readOutput().contains("Created new package"));
Assert.assertTrue(output.contains("What's next"));
Assert.assertTrue(output.contains("Execute the below command to run the program:"));
Assert.assertTrue(output.contains("\t bal run " + name));
Assert.assertTrue(output.contains("Else, execute the below command to build the executable JAR file:"));
Assert.assertTrue(output.contains("\t bal build " + name));

Assert.assertTrue(Files.exists(packageDir.resolve(".devcontainer.json")));
String devcontainerContent = Files.readString(packageDir.resolve(".devcontainer.json"));
Expand Down
Loading