package com.lousylynx.asciidots.cli;

import org.apache.commons.cli.*;

public class ADCLI {

    private static boolean exit = false;

    public static void main(String[] args) {
        handleArguments(args);

        if(exit)
            System.exit(0);
    }

    private static void handleArguments(String[] args) {
        Options options = new Options();



//        options.addOption(Option.builder()
//                .longOpt("file")
//                .hasArg()
//                .build());

        options.addOption("file", true, FILE_OPTION);
        options.addOption("help", false, "Print the help command");
        options.addOption("t", "ticks", false, "Run the program for a specified number of ticks");
        options.addOption("s", "silent", false, "Run without printing ANYTHING to the console. Useful for benchmarking");
        options.addOption("d", "debug", false, "Run the program in debug mode. It shows the program and highlights the dots with red. Press enter to step the program once.");
        options.addOption("w", "compat_debug", false, "Run the program without using ncurses. This can fix problems related to Windows.");
        options.addOption("l", "debug_lines", false, "When not in compatibility mode, reserve the specified number of the lines for displaying the program");
        options.addOption("a", "autostep_debug", false, "Step the program automatically, using the specified delay in seconds. Decimal numbers are permitted, and so is 0.");
        options.addOption("h", "head", false, "TODO: add description here");

        try {
            CommandLine cmd = new DefaultParser().parse(options, args);

            if(cmd.hasOption("help")) {
                HelpFormatter formatter = new HelpFormatter();
                formatter.printHelp("asciidots", options);

                exit = true;
                return;
            }

            System.out.println(cmd.getOptionValue("filename"));
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
}

@@ -216,16 +216,17 @@
       if
+ 
 (exit)%0A 
@@ -362,12 +362,8 @@
 );%0A%0A
-%0A%0A//
     
@@ -388,118 +388,56 @@
 ion(
-Option.builder()%0A//                .longOpt(%22file%22)%0A//                .hasArg()%0A//                .build()
+null, %22help%22, false, %22Print the help command%22
 );%0A
-%0A
     
@@ -463,66 +463,20 @@
 on(%22
-file%22, true, FILE_OPTION);%0A        options.addOption(%22help
+v%22, %22version
 %22, f
@@ -487,33 +487,47 @@
 , %22Print
+s
  the 
-help comm
+current version being r
 an
-d
 %22);%0A    
@@ -1546,24 +1546,31 @@
 ptions, args
+, false
 );%0A%0A        
@@ -1575,16 +1575,17 @@
       if
+ 
 (cmd.has
@@ -1711,16 +1711,23 @@
 sciidots
+ %3CFILE%3E
 %22, optio
@@ -1728,16 +1728,22 @@
  options
+, true
 );%0A%0A    
@@ -1822,139 +1822,977 @@
     
-System.out.println(cmd.getOptionValue(%22filename%22));%0A        %7D catch (ParseException e) %7B%0A            e.printStackTrace();%0A        %7D
+if (cmd.hasOption(%22version%22)) %7B%0A                // TODO: make this non hardcoded%0A                System.out.println(%22Current version is: 1.0%22);%0A%0A                exit = true;%0A                return;%0A            %7D%0A%0A            if (cmd.getArgs().length %3E 1) %7B%0A                System.out.println(%22Unknown stray arguments: %22 + String.join(%22, %22, cmd.getArgList()));%0A%0A                exit = true;%0A                return;%0A            %7D else if (cmd.getArgs().length %3C 1) %7B%0A                System.out.println(%22You must specify a file to run.%22);%0A%0A                exit = true;%0A                return;%0A            %7D%0A%0A            String program = getFile(cmd);%0A%0A            // TODO: Run the interpreter from here%0A        %7D catch (ParseException e) %7B%0A            e.printStackTrace();%0A        %7D%0A    %7D%0A%0A    private static String getFile(CommandLine cmd) %7B%0A        String file = cmd.getArgs()%5B0%5D;%0A%0A        // TODO: continue reading the file and output the contents%0A%0A        return file;
 %0A   

Update argument parser to retrieve the file