package examples.dustin.commandline.jbock;

import static java.lang.System.out;

import net.jbock.CommandLineArguments;
import net.jbock.Description;
import net.jbock.LongName;
import net.jbock.ShortName;

import java.util.Optional;

/**
 * Demonstrates use of jbock to process command-line
 * arguments in a Java application.
 */
public class Main
{
   private boolean verbose;
   private String file;

   @CommandLineArguments
   abstract static class Arguments
   {

      @ShortName('v') @LongName("verbose") @Description("Verbosity enabled?")
      abstract boolean verbose();

      @ShortName('f') @LongName("file") @Description("File name and path")
      abstract Optional<String> file();
   }

   public Main(Arguments arguments)
   {
      verbose = arguments.verbose();
      file = arguments.file().orElse("");
   }

   public String getFile()
   {
      return file;
   }

   public boolean isVerbose()
   {
      return verbose;
   }

   public static void main(final String[] arguments)
   {
      if (arguments.length < 1)
      {
         Main_Arguments_Parser.printUsage(out, 3);
         System.exit(-1);
      }
      final Main main = new Main(Main_Arguments_Parser.parse(arguments));
      out.println("The file '" + main.getFile() + "' was provided and verbosity is set to '" + main.isVerbose() + "'.");
   }
}

@@ -347,60 +347,8 @@
 in%0A%7B
-%0A   private boolean verbose;%0A   private String file;
 %0A%0A  
@@ -618,24 +618,14 @@
 act 
-Optional%3C
 String
-%3E
  fil
@@ -639,254 +639,8 @@
  %7D%0A%0A
-   public Main(Arguments arguments)%0A   %7B%0A      verbose = arguments.verbose();%0A      file = arguments.file().orElse(%22%22);%0A   %7D%0A%0A   public String getFile()%0A   %7B%0A      return file;%0A   %7D%0A%0A   public boolean isVerbose()%0A   %7B%0A      return verbose;%0A   %7D%0A%0A
    p
@@ -662,22 +662,16 @@
 id main(
-final 
 String%5B%5D
@@ -697,207 +697,113 @@
     
-if (arguments.length %3C 1)%0A      %7B%0A         Main_Arguments_Parser.printUsage(out, 3);%0A         System.exit(-1);%0A      %7D%0A      final Main main = new Main(Main_Arguments_Parser.parse(arguments));%0A      
+Main_Arguments_Parser.parse(arguments, System.out)%0A        .ifPresentOrElse(args -%3E%0A              System.
 out.
@@ -829,17 +829,14 @@
 %22 + 
-main.getF
+args.f
 ile(
@@ -888,16 +888,14 @@
 %22 + 
-main.isV
+args.v
 erbo
@@ -906,16 +906,53 @@
  + %22'.%22)
+,%0A              () -%3E System.exit(1))
 ;%0A   %7D%0A%7D

update to jbock 2.3