package sample;

import java.util.List;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;

import static util.Utils.*;

public class Main {

    public static void main(String[] args) throws Exception {
        for(int i=0; i<args.length; i++){
            putsf("arg[%s] (%s)", i, args[i]);
        }

        String currentDir = args[0];
        String projectDir = args[1];
        String[] mainArgs = new String[args.length - 2];
        for(int i=2; i<args.length; i++){
            mainArgs[i-2] = args[i];
        }

        Options opts = new Options();
        opts.addOption("h", "help", false, "Print help");

        opts.addOption(Option.builder("v")
                .hasArg()
                .desc("Print version")
                .build());

        CommandLine cl = new DefaultParser().parse(opts, mainArgs);

        List<String> restArgs = cl.getArgList();
        putsf("currentDir (%s)", currentDir);
        putsf("projectDir (%s)", projectDir);
        putsf("restArgs size (%s)", restArgs.size());

        for(int i=0; i<restArgs.size(); i++){
            putsf("arg[%s] (%s)", i, restArgs.get(i));
        }

        puts(cl.hasOption("h"));
        puts(cl.hasOption("v"));

        String content = readFile("README.md");
        puts(content);
    }

}

@@ -287,17 +287,20 @@
 tring%5B%5D 
-a
+rawA
 rgs) thr
@@ -334,25 +334,28 @@
 (int i=0; i%3C
-a
+rawA
 rgs.length; 
@@ -371,39 +371,42 @@
          putsf(%22
+raw 
 arg
-%5B
+ 
 %25s
-%5D
  (%25s)%22, i, args%5B
@@ -400,17 +400,20 @@
 s)%22, i, 
-a
+rawA
 rgs%5Bi%5D);
@@ -448,25 +448,28 @@
 urrentDir = 
-a
+rawA
 rgs%5B0%5D;%0A    
@@ -492,17 +492,20 @@
 ctDir = 
-a
+rawA
 rgs%5B1%5D;%0A
@@ -543,17 +543,20 @@
  String%5B
-a
+rawA
 rgs.leng
@@ -587,17 +587,20 @@
  i=2; i%3C
-a
+rawA
 rgs.leng
@@ -637,17 +637,20 @@
 %5Bi-2%5D = 
-a
+rawA
 rgs%5Bi%5D;%0A

rename var