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

Refactor CLI tests and improvements on the -version option #1590

Merged
merged 3 commits into from
Dec 29, 2024
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
23 changes: 13 additions & 10 deletions src/main/java/com/adobe/epubcheck/tool/EpubChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public class EpubChecker
File listChecksOut;
File customMessageFile;
boolean listChecks = false;
boolean displayHelpOrVersion = false;
boolean displayHelp = false;
boolean displayVersion = false;
boolean useCustomMessageFile = false;
boolean failOnWarnings = false;
private Messages messages = Messages.getInstance();
Expand Down Expand Up @@ -132,17 +133,17 @@ public int run(String[] args)
{
if (processArguments(args))
{
if (displayHelp || (displayVersion && path == null))
{
return 0;
}
report = createReport();
report.initialize();
if (listChecks)
{
dumpMessageDictionary(report);
return 0;
}
if (displayHelpOrVersion)
{
return 0;
}
if (useCustomMessageFile)
{
report.setCustomMessageFile(customMessageFile.getAbsolutePath());
Expand All @@ -159,7 +160,9 @@ public int run(String[] args)
returnValue = 1;
} finally
{
printEpubCheckCompleted(report);
if (report != null) {
printEpubCheckCompleted(report);
}
}
return returnValue;
}
Expand Down Expand Up @@ -743,11 +746,11 @@ else if (!fileName.startsWith("-"))
case "?":
case "help":
displayHelp(); // display help message
displayHelpOrVersion = true;
break;
displayHelp = true;
break;
case "version":
displayVersion();
displayHelpOrVersion = true;
displayVersion = true;
break;
default:
System.err.println(String.format(messages.get("unrecognized_argument"), args[i]));
Expand Down Expand Up @@ -796,7 +799,7 @@ else if (!fileName.startsWith("-"))

if (path == null)
{
if (listChecks || displayHelpOrVersion)
if (listChecks || displayHelp || displayVersion)
{
return true;
}
Expand Down
Loading
Loading