Let IntelliJ format all files
This commit is contained in:
parent
eb64994b5a
commit
99c1bb4d6a
5 changed files with 36 additions and 56 deletions
|
@ -4,19 +4,13 @@ import org.apache.commons.cli.Option;
|
||||||
import org.apache.commons.cli.Options;
|
import org.apache.commons.cli.Options;
|
||||||
|
|
||||||
final class AppOptions {
|
final class AppOptions {
|
||||||
|
public final static Option help = Option.builder().argName("h").longOpt("help").desc("Shows this help " + "message and exits").build();
|
||||||
|
public final static Option version = Option.builder().argName("v").longOpt("version").desc("Shows version information and exits").build();
|
||||||
|
private final static Options options = new Options().addOption(help).addOption(version);
|
||||||
|
|
||||||
// Disable Instance Creation
|
// Disable Instance Creation
|
||||||
private AppOptions() {}
|
private AppOptions() {}
|
||||||
|
|
||||||
public final static Option help =
|
|
||||||
Option.builder().argName("h").longOpt("help").desc("Shows this help " +
|
|
||||||
"message and exits").build();
|
|
||||||
public final static Option version =
|
|
||||||
Option.builder().argName("v").longOpt("version").desc("Shows version information and exits").build();
|
|
||||||
|
|
||||||
private final static Options options = new Options()
|
|
||||||
.addOption(help)
|
|
||||||
.addOption(version);
|
|
||||||
|
|
||||||
public static Options getOptions() {
|
public static Options getOptions() {
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,5 @@ import java.util.Locale;
|
||||||
|
|
||||||
public record GlobalConf() {
|
public record GlobalConf() {
|
||||||
public static final String langGerman = "de";
|
public static final String langGerman = "de";
|
||||||
public static final String applicationOutputLanguage = (Locale.getDefault().getLanguage().equals(Locale.GERMAN.getLanguage()))
|
public static final String applicationOutputLanguage = (Locale.getDefault().getLanguage().equals(Locale.GERMAN.getLanguage())) ? Locale.GERMAN.getLanguage() : Locale.ENGLISH.getLanguage();
|
||||||
? Locale.GERMAN.getLanguage()
|
|
||||||
: Locale.ENGLISH.getLanguage();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,11 +56,7 @@ public final class Main {
|
||||||
|
|
||||||
public static void main(final String[] args) {
|
public static void main(final String[] args) {
|
||||||
try {
|
try {
|
||||||
final var parsedArguments =
|
final var parsedArguments = DefaultParser.builder().setStripLeadingAndTrailingQuotes(true).build().parse(AppOptions.getOptions(), args);
|
||||||
DefaultParser.builder()
|
|
||||||
.setStripLeadingAndTrailingQuotes(true)
|
|
||||||
.build()
|
|
||||||
.parse(AppOptions.getOptions(), args);
|
|
||||||
|
|
||||||
final var userData = parsedArguments.getArgs();
|
final var userData = parsedArguments.getArgs();
|
||||||
|
|
||||||
|
@ -70,29 +66,22 @@ public final class Main {
|
||||||
printVersionInformation();
|
printVersionInformation();
|
||||||
} else if (userData.length == 0) {
|
} else if (userData.length == 0) {
|
||||||
switch (applicationOutputLanguage) {
|
switch (applicationOutputLanguage) {
|
||||||
case GlobalConf.langGerman -> logger.log(Level.ERROR,
|
case GlobalConf.langGerman -> logger.log(Level.ERROR, "Es wurde keine Uhrzeit angegeben.");
|
||||||
"Es wurde keine Uhrzeit angegeben.");
|
default -> logger.log(Level.ERROR, "No target time" + " was " + "provided.");
|
||||||
default -> logger.log(Level.ERROR, "No target time" +
|
|
||||||
" was " +
|
|
||||||
"provided.");
|
|
||||||
}
|
}
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
} else if (userData.length > 1) {
|
} else if (userData.length > 1) {
|
||||||
switch (applicationOutputLanguage) {
|
switch (applicationOutputLanguage) {
|
||||||
case GlobalConf.langGerman -> logger.log(Level.ERROR,
|
case GlobalConf.langGerman -> logger.log(Level.ERROR, "Zu viele Argumente wurden angegeben.");
|
||||||
"Zu viele Argumente wurden angegeben.");
|
default -> logger.log(Level.ERROR, "Too many arguments " + "provided.");
|
||||||
default -> logger.log(Level.ERROR, "Too many arguments " +
|
|
||||||
"provided.");
|
|
||||||
}
|
}
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
} else {
|
} else {
|
||||||
final var target =
|
final var target = TimeCalculator.calculateAndAnnounceTargetTime(userData[0]);
|
||||||
TimeCalculator.calculateAndAnnounceTargetTime(userData[0]);
|
|
||||||
Sleep.waitUntilTimeStamp(target);
|
Sleep.waitUntilTimeStamp(target);
|
||||||
}
|
}
|
||||||
} catch (final ParseException e) {
|
} catch (final ParseException e) {
|
||||||
System.getLogger("main").log(Level.ERROR, "Parsing " +
|
System.getLogger("main").log(Level.ERROR, "Parsing " + "of arguments failed and the program cannot continue.", e);
|
||||||
"of arguments failed and the program cannot continue.", e);
|
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,7 @@ import java.time.ZonedDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.format.FormatStyle;
|
import java.time.format.FormatStyle;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.*;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import java.lang.Math;
|
|
||||||
|
|
||||||
public final class Sleep {
|
public final class Sleep {
|
||||||
public static void waitUntilTimeStamp(ZonedDateTime timestamp) {
|
public static void waitUntilTimeStamp(ZonedDateTime timestamp) {
|
||||||
|
|
|
@ -24,7 +24,8 @@ import java.time.LocalTime;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.format.FormatStyle;
|
import java.time.format.FormatStyle;
|
||||||
import java.util.*;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import static java.lang.System.Logger.Level;
|
import static java.lang.System.Logger.Level;
|
||||||
|
|
||||||
public final class TimeCalculator {
|
public final class TimeCalculator {
|
||||||
|
|
Loading…
Reference in a new issue