Skip to content

Commit

Permalink
catch interrupt exception
Browse files Browse the repository at this point in the history
  • Loading branch information
strogiyotec committed Aug 11, 2020
1 parent b46d140 commit ae9798b
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/main/java/jfill/Execution.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,20 @@ final class Execution {
* @throws Exception If failed
*/
void execute() throws Exception {
if (this.helpOrVersion()) {
return;
}
var storage = this.resolver.resolve(new Arguments(this.args));
try {
new ShellCommand(
this.args,
storage,
this.builder
).execute();
//save new valuesResolver in cache
storage.flush(this.cache);
} catch (final UserInterruptException exc) {
//Do nothing
if (!this.helpOrVersion()) {
try {
var resolvedValues = this.resolver.resolve(new Arguments(this.args));
new ShellCommand(
this.args,
resolvedValues,
this.builder
).execute();
//save new valuesResolver in cache
resolvedValues.flush(this.cache);
} catch (final UserInterruptException exc) {
//Do nothing
}
}
this.cache.save();
}

private void printHelp() {
Expand All @@ -75,6 +73,12 @@ private void printVersion() {
this.output.println(Defaults.VERSION);
}

/**
* Check if jfill should print help or version.
* If so then print it
*
* @return If help or version was printed
*/
private boolean helpOrVersion() {
if (this.args.length == 0) {
this.printHelp();
Expand Down

0 comments on commit ae9798b

Please sign in to comment.