From 2c0ea7b0663a4408f3694f10248f058047a68a83 Mon Sep 17 00:00:00 2001 From: Arvanitis Christos Date: Thu, 12 Oct 2017 11:12:10 +0300 Subject: [PATCH] Added -v, --version flag (#54) * Added -v, --version flag * Added -v entry in help info * Minimum check optimization for if else part * Rewrite shortest version --- src/main/java/com/rarchives/ripme/App.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/com/rarchives/ripme/App.java b/src/main/java/com/rarchives/ripme/App.java index a1728fe6..5d3ec550 100644 --- a/src/main/java/com/rarchives/ripme/App.java +++ b/src/main/java/com/rarchives/ripme/App.java @@ -39,6 +39,13 @@ public class App { private static final History HISTORY = new History(); public static void main(String[] args) throws MalformedURLException { + CommandLine cl = getArgs(args); + if (args.length > 0 && cl.hasOption('v')){ + System.out.println(UpdateUtils.getThisJarVersion()); + System.exit(0); + } + + //initialize logger Utils.configureLogger(); System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", "RipMe"); @@ -46,8 +53,10 @@ public class App { logger.info("Initialized ripme v" + UpdateUtils.getThisJarVersion()); if (args.length > 0) { + // CLI Mode handleArguments(args); } else { + // GUI Mode MainWindow mw = new MainWindow(); SwingUtilities.invokeLater(mw); } @@ -198,6 +207,7 @@ public class App { opts.addOption("l", "ripsdirectory", true, "Rips Directory (Default: ./rips)"); opts.addOption("n", "no-prop-file", false, "Do not create properties file."); opts.addOption("f", "urls-file", true, "Rip URLs from a file."); + opts.addOption("v", "version", false, "Show current version"); return opts; }