Skip to content

Commit

Permalink
Updated App.java
Browse files Browse the repository at this point in the history
  • Loading branch information
alina tarasova committed May 2, 2024
1 parent 6d4f4b2 commit f44b954
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions app/src/main/java/hexlet/code/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
import picocli.CommandLine.Parameters;
import java.util.concurrent.Callable;


@Command(name = "gendiff", mixinStandardHelpOptions = true, version = "gendiff 4.7.5",
description = "Compares two configuration files and shows a difference.")
public class App implements Callable<Integer> {
public final class App implements Callable<Integer> {

private static final int SUCCESS_EXIT_CODE = 0;
private static final int ERROR_EXIT_CODE = 1;

@Parameters(index = "0", description = "path to first file")
//@Parameters(description = "path to first file")
Expand All @@ -22,13 +26,20 @@ public class App implements Callable<Integer> {

/**
* @return returns a string of differences between 2 files
* @throws Exception if files not exist
*/
@Override
public Integer call() throws Exception {
String file = Differ.generate(filepath1, filepath2, format);
System.out.println(file);
return 0;
public Integer call() {

try {
String formattedDiff = Differ.generate(filepath1, filepath2, format);
System.out.println(formattedDiff);

} catch (Exception e) {
System.err.println(e.getMessage());
return ERROR_EXIT_CODE;
}

return SUCCESS_EXIT_CODE;
}

public static void main(String... args) {
Expand Down

0 comments on commit f44b954

Please sign in to comment.