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

removed exception that was used to differenciate between test and pro… #1

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 @@ -50,8 +50,9 @@ public void initAdaptTemplatesTest() throws URISyntaxException, IOException {
@Test
public void adaptTemplatesTest() throws Exception {

String args[] = new String[1];
String args[] = new String[2];
args[0] = "adapt-templates";
args[1] = "--all";

execute(args, false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.devonfw.cobigen.impl.adapter.TemplateAdapterImpl;

import picocli.CommandLine.Command;
import picocli.CommandLine.Option;

/**
* This class handles the user defined template directory e.g. determining and obtaining the latest templates jar,
Expand All @@ -30,6 +31,12 @@ public class AdaptTemplatesCommand extends CommandCommons {
*/
private static Logger LOG = LoggerFactory.getLogger(CobiGenCLI.class);

/**
* If this options is enabled, all templates are unpacked.
*/
@Option(names = { "--all" }, negatable = true, description = MessagesConstants.UPDATE_ALL_DESCRIPTION)
boolean adaptAll;

@Override
public Integer doAction() throws Exception {

Expand Down Expand Up @@ -74,9 +81,13 @@ private List<Path> getJarsToAdapt(TemplateAdapter templateAdapter, List<Path> te
printJarsForSelection(templateAdapter, templateJars);

List<String> userSelection = new ArrayList<>();
for (String templateSelection : ValidationUtils.getUserInput().split(",")) {
userSelection.add(templateSelection);
}

if (this.adaptAll)
userSelection.add("0");
else
for (String templateSelection : ValidationUtils.getUserInput().split(",")) {
userSelection.add(templateSelection);
}

if (userSelection.contains("0")) {
jarsToAdapt = templateJars;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.util.Scanner;

import org.slf4j.Logger;
Expand Down Expand Up @@ -131,14 +130,7 @@ public static void throwNoTriggersMatched(Path inputFile, boolean isJavaInput, b
public static String getUserInput() {

String userInput = "";
try {
userInput = inputReader.nextLine();
} catch (NoSuchElementException e) {
// This Case is for the Adapt-templates Command to cover the next line in Test adaptTemplatesTest when no
// UserInput can be scanned
LOG.info("No User Input, By default All found templates will be adapted");
userInput = "0";
}
return userInput;
}

Expand Down