Skip to content

Commit

Permalink
Added a commandline option to bypass the bootloader
Browse files Browse the repository at this point in the history
and corrected the reported version number
  • Loading branch information
ccavanaugh committed Mar 31, 2019
1 parent 4e4d2c7 commit 247d987
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 7 deletions.
29 changes: 27 additions & 2 deletions bootloader/src/main/java/jGnash.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,42 @@

import java.awt.EventQueue;

import picocli.CommandLine;

import static jgnash.util.LogUtil.logSevere;

/**
* Bootstrap a modular jGnashFx by downloading platform specific OpenJFX libraries and then launching the application
* Bootstraps a modular jGnashFx by downloading platform specific OpenJFX libraries and then launching the application
*
* @author Craig Cavanaugh
*/
public class jGnash {

public static void main(final String[] args) {

boolean bypassBootLoader = false;

final CommandLine commandLine = new CommandLine(new jGnashFx.CommandLineOptions());
commandLine.setToggleBooleanFlags(false);
commandLine.setUsageHelpWidth(80);

try {
final CommandLine.ParseResult pr = commandLine.parseArgs(args);
final jGnashFx.CommandLineOptions options = commandLine.getCommand();

if (CommandLine.printHelpIfRequested(pr)) {
System.exit(0);
}

bypassBootLoader = options.bypassBootloader;
} catch (final Exception e) {
logSevere(jGnash.class, e);
commandLine.usage(System.err, CommandLine.Help.Ansi.AUTO);
System.exit(1);
}

if (BootLoader.getOS() != null) {
if (BootLoader.doFilesExist()) {
if (bypassBootLoader || BootLoader.doFilesExist()) {
launch(args);
} else {

Expand Down
2 changes: 2 additions & 0 deletions changelog.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
* Write and replace for bxds and xml files to protect against corruption if a crash occurs during a save.
== Release 3.0.2
* 03/31/2019 Added a commandline option to bypass the bootloader.
* 03/31/2019 The wrong version information ws being reported on the console when requested.
* 03/30/2019 Automatic column widths will now update correctly if numeric or date formats change.
* 03/30/2019 Use a full commodity format for the Total column in the investment register.
* 03/30/2019 Changes to preferred date and numeric formats will now trigger an immediate update of the active register.
Expand Down
28 changes: 23 additions & 5 deletions jgnash-fx/src/main/java/jGnashFx.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.util.logging.Logger;
import java.util.prefs.Preferences;

import javax.swing.*;
import javax.swing.JOptionPane;

import javafx.application.Application;
import javafx.stage.Stage;
Expand All @@ -36,19 +36,26 @@
import jgnash.engine.message.MessageBus;
import jgnash.resource.util.OS;
import jgnash.resource.util.ResourceUtils;
import jgnash.resource.util.Version;
import jgnash.uifx.StaticUIMethods;
import jgnash.uifx.net.NetworkAuthenticator;
import jgnash.uifx.views.main.MainView;
import jgnash.util.FileUtils;
import jgnash.util.LogUtil;
import jgnash.util.prefs.PortablePreferences;

import picocli.CommandLine;

import static picocli.CommandLine.Command;
import static picocli.CommandLine.Help;
import static picocli.CommandLine.IVersionProvider;
import static picocli.CommandLine.Option;
import static picocli.CommandLine.ParseResult;

import static jgnash.util.LogUtil.logSevere;
import static picocli.CommandLine.*;

/**
* Main entry for the application.
* Main entry point for the application.
* <p>
* This bootstraps the JavaFX application and lives in the default class as a workaround for
* Gnome and OSX menu naming issues.
Expand Down Expand Up @@ -218,8 +225,8 @@ private static void configureLogging() {
Engine.getLogger().setLevel(Level.ALL);
}

@Command(mixinStandardHelpOptions = true, version = "jGnashFx - " + VERSION, name = "jGnashFx", separator = " ", sortOptions = false)
private static class CommandLineOptions {
@Command(mixinStandardHelpOptions = true, versionProvider = CommandLineOptions.VersionProvider.class, name = "jGnash", separator = " ", sortOptions = false)
public static class CommandLineOptions {

private static final String FILE_OPTION_SHORT = "-f";
private static final String FILE_OPTION_LONG = "--file";
Expand All @@ -235,6 +242,7 @@ private static class CommandLineOptions {
private static final String PASSWORD_OPTION = "--password";
private static final String SERVER_OPTION = "--server";
private static final String SHUTDOWN_OPTION = "--shutdown";
private static final String BYPASS_BOOTLOADER = "--bypassBootloader";
//private static final String SSL_OPTION = "--ssl";

@CommandLine.Parameters(index = "0", arity = "0")
Expand Down Expand Up @@ -272,5 +280,15 @@ private static class CommandLineOptions {

@Option(names = {VERBOSE_OPTION_SHORT, VERBOSE_OPTION_LONG}, description = "Enable verbose application messages")
private boolean verbose = false;

@CommandLine.Option(names = {BYPASS_BOOTLOADER}, description = "Bypasses the bootloader and requires manual installation of OS specific files")
public boolean bypassBootloader = false;

static class VersionProvider implements IVersionProvider {
@Override
public String[] getVersion() {
return new String[] {Version.getAppName() + " " + Version.getAppVersion()};
}
}
}
}

0 comments on commit 247d987

Please sign in to comment.