Skip to content
Snippets Groups Projects
Commit 25fb9881 authored by Vojtech Moravec's avatar Vojtech Moravec
Browse files

Modify the error message of CLI app.

parent 0da73e45
Branches
No related tags found
No related merge requests found
......@@ -12,6 +12,7 @@ import azgracompress.fileformat.FileExtensions;
import org.apache.commons.cli.*;
import java.io.IOException;
import java.util.Optional;
public class DataCompressor {
public static void main(String[] args) {
......@@ -27,8 +28,12 @@ public class DataCompressor {
formatter.printHelp(CliConstants.MAIN_HELP, options);
return;
}
if (e.getMessage().startsWith("Missing required option:")) {
System.err.println("Error: Missing required option, see usage below. :^)");
formatter.printHelp(CliConstants.MAIN_HELP, options);
} else {
System.err.println("Error: " + e.getMessage());
}
return;
}
......
package azgracompress.cli;
public class ParseResult<T> {
private final boolean success;
private final T value;
private final String errorMessage;
public ParseResult(final String errorMessage) {
this.success = false;
this.value = null;
this.errorMessage = errorMessage;
}
public ParseResult(T value) {
this.success = true;
this.value = value;
this.errorMessage = null;
}
public boolean isSuccess() {
return success;
}
public T getValue() {
return value;
}
public String getErrorMessage() {
return errorMessage;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment