From 0e9aa1700b740504689f7a0feb1eb3de1a32ef22 Mon Sep 17 00:00:00 2001 From: Ryuu Mitsuki <117973493+mitsuki31@users.noreply.github.com> Date: Tue, 20 Jun 2023 21:19:34 +0700 Subject: [PATCH] Improve the `Main` class --- src/main/java/com/mitsuki/jmatrix/Main.java | 70 ++++++++++++++------- 1 file changed, 46 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/mitsuki/jmatrix/Main.java b/src/main/java/com/mitsuki/jmatrix/Main.java index 77f8f07..19125dc 100644 --- a/src/main/java/com/mitsuki/jmatrix/Main.java +++ b/src/main/java/com/mitsuki/jmatrix/Main.java @@ -3,25 +3,39 @@ import com.mitsuki.jmatrix.util.Options; import com.mitsuki.jmatrix.util.XMLParser; +/** + * Main class for JMatrix library that provides some information such as JMatrix version. + * + *
This class does not provides API for build the matrix, + * it's just useless class if get imported. + * + *
Usage:
+ * + *+ * java -jar path/to/jmatrix.jar [-h|-V|-cr] + *+ * + * @author + * Ryuu Mitsuki + * @version 1.2, 20 June 2023 + * @since 1.0.0 + * @see com.mitsuki.jmatrix.Matrix + */ public class Main { + private static XMLParser XML = new XMLParser(XMLParser.XMLType.CONFIG); + private static String programVersion = XML.getProperty("programName") + " " + getVersion(); + public static void main(String[ ] args) { String arg1 = null; - String arg2 = null; - - XMLParser XML = new XMLParser(XMLParser.XMLType.CONFIG); if (args.length >= 1 && args.length < 2) { arg1 = args[0]; - if (args.length == 2) { - arg2 = args[1]; - } - } - else if (args.length > 1) { + } else if (args.length > 1) { try { throw new IllegalArgumentException("Too much arguments"); - } catch (final Exception e) { - Options.raiseErrorMsg(e, 0); + } catch (final IllegalArgumentException iae) { + Options.raiseErrorMsg(iae, 0); System.out.println(Options.getHelpMsg()[0]); System.out.println(" " + "java -jar