package edu.pdx.cs410J.chances;

import edu.pdx.cs410J.AbstractAppointmentBook;

import java.util.Arrays;
import java.util.List;

/**
 * The main class for the CS410J appointment book Project
 */
public class Project1 {

  public static void main(String[] args) {
    // Refer to one of Dave's classes so that we can be sure it is on the classpath
    Class c = AbstractAppointmentBook.class;

    List<String> argsList = Arrays.asList(args);

    // Print the README if flag is present
    if (argsList.contains("-README")) {
      System.out.println("Chance Snow - Project 1\n" +
              "\tAppointment Book Application\n\n" +
              "Create an appointment in a new appointment book.\n");
      System.out.print("usage: java edu.pdx.cs410J.chances.Project1 [options] <args>\n" +
              "\targs are (in this order):\n" +
              "\t\towner The person whose owns the appt book\n" +
              "\t\tdescription A description of the appointment\n" +
              "\t\tbeginTime When the appt begins (24-hour time)\n" +
              "\t\tendTime When the appt ends (24-hour time)\n" +
              "\toptions are (options may appear in any order):\n" +
              "\t\t-print Prints a description of the new appointment\n" +
              "\t\t-README Prints a README for this project and exits\n" +
              "\tDate and time should be in the format: mm/dd/yyyy hh:mm\n");

      System.exit(0);
    }

    for (String arg : args) {
      System.out.println(arg);
    }

    // Default to error
    System.err.println("Missing command line arguments");
    System.exit(1);
  }

}

/*

The -print option cannot appear after the args, but the options can appear in any order.  That is, a command line like

$ java -jar target/apptbook-1.0-SNAPSHOT.jar Dave -print 7/15/2016 14:39  7/15/2016 15:39

should create an appointment whose description is "-print".  Note that I won't test this case, though.

A command line like

$ java -jar target/apptbook-1.0-SNAPSHOT.jar Dave "Save the whales" 7/15/2016 14:39  7/15/2016 15:39 -print

should issue an error because there are extraneous command line arguments.

A command line like:

$ java -jar target/apptbook-1.0-SNAPSHOT.jar -print -README Dave "Save the whales" 7/15/2016 14:39  7/15/2016 15:39

should print the README and exit because that's what you always do when -README is provided.

 */

@@ -234,498 +234,43 @@
 tic 
-void main(String%5B%5D args) %7B%0A    // Refer to one of Dave's classes so that we can be sure it is on the classpath%0A    Class c = AbstractAppointmentBook.class;%0A%0A    List%3CString%3E argsList = Arrays.asList(args);%0A%0A    // Print the README if flag is present%0A    if (argsList.contains(%22-README%22)) %7B%0A      System.out.println(%22Chance Snow - Project 1%5Cn%22 +%0A              %22%5CtAppointment Book Application%5Cn%5Cn%22 +%0A              %22Create an appointment in a new appointment book.%5Cn%22);%0A      System.out.print(
+final String USAGE_DOCUMENTATION = 
 %22usa
@@ -342,20 +342,16 @@
         
-    
 %22%5Ctargs 
@@ -368,36 +368,32 @@
 is order):%5Cn%22 +%0A
-    
           %22%5Ct%5Cto
@@ -444,28 +444,24 @@
 +%0A          
-    
 %22%5Ct%5Ctdescrip
@@ -495,36 +495,32 @@
 ppointment%5Cn%22 +%0A
-    
           %22%5Ct%5Ctb
@@ -575,28 +575,24 @@
 +%0A          
-    
 %22%5Ct%5CtendTime
@@ -627,28 +627,24 @@
  time)%5Cn%22 +%0A
-    
           %22%5C
@@ -702,28 +702,24 @@
 +%0A          
-    
 %22%5Ct%5Ct-print 
@@ -763,28 +763,24 @@
 ntment%5Cn%22 +%0A
-    
           %22%5C
@@ -848,20 +848,16 @@
         
-    
 %22%5CtDate 
@@ -906,19 +906,545 @@
 yy hh:mm
-%5Cn%22
+%22;%0A%0A  public static void main(String%5B%5D args) %7B%0A    // Refer to one of Dave's classes so that we can be sure it is on the classpath%0A    Class c = AbstractAppointmentBook.class;%0A%0A    List%3CString%3E argsList = Arrays.asList(args);%0A%0A    // Print the README if flag is present%0A    if (argsList.contains(%22-README%22)) %7B%0A      System.out.println(%22Chance Snow - Project 1%5Cn%22 +%0A              %22%5CtAppointment Book Application%5Cn%5Cn%22 +%0A              %22Create an appointment in a new appointment book.%5Cn%22);%0A      System.out.print(USAGE_DOCUMENTATION
 );%0A%0A    

Refactor usage instructions into constant