package org.puller;

import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.OptionHandlerRegistry;
import org.puller.comixology.Comixology;

import java.time.LocalDate;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

public class Puller {
    public static void main(String[] args) {
        OptionHandlerRegistry.getRegistry().registerHandler(LocalDate.class, DateOptionHandler.class);
        final PullerOptions options = new PullerOptions();
        final CmdLineParser parser = new CmdLineParser(options);
        try {
            parser.parseArgument(args);

            if (options.getUsername() == null) {
                throw new CmdLineException(parser, new LocalizedString("The username is missing"));
            }

            if (options.getPassword() == null) {
                throw new CmdLineException(parser, new LocalizedString("The password is missing"));
            }

            pull(options);

            if (!options.isDryRun()) {
                new Configuration(options.getUsername(), options.getPassword(), options.getTo()).save();
            }
        } catch (CmdLineException e) {
            System.err.println(e.getMessage());
            System.err.println("usage: puller [options]");
            new CmdLineParser(new PullerOptions()).printUsage(System.err);
        }
    }

    private static void pull(final PullerOptions options) {
        final Comixology comixology = new Comixology(options.getUsername(), options.getPassword());
        final List<LocalDate> wednesdays = Dates.getWednesdays(options.getFrom(), options.getTo());
        final List<Comic> comics = wednesdays.stream()
                .map(comixology::getWeeklyPullList)
                .flatMap(Collection::stream)
                .collect(Collectors.toList());

        comics.stream().sorted().forEach(System.out::println);
        System.out.println("-------------------------------");
        System.out.println(comics.stream().map(Comic::getRawPrice).collect(Collectors.summingDouble(Double::valueOf)));
    }
}

@@ -218,16 +218,59 @@
 alDate;%0A
+import java.time.format.DateTimeFormatter;%0A
 import j
@@ -1707,24 +1707,201 @@
 s.getTo());%0A
+%0A        System.out.println(String.format(%22Fetching Comixology pull list for %25s from %25s to %25s...%22, options.getUsername(),%0A                options.getFrom(), options.getTo()));%0A%0A
         fina
@@ -2084,24 +2084,251 @@
 toList());%0A%0A
+        System.out.println();%0A        System.out.println(String.format(%22%25s's pull list from %25s to %25s%22, options.getUsername(), options.getFrom(), options.getTo()));%0A        System.out.println(%22-------------------------------%22);%0A
         comi
@@ -2468,16 +2468,64 @@
 println(
+String.format(%22Total = $%255.2f%22,%0A                
 comics.s
@@ -2607,16 +2607,17 @@
 lueOf)))
+)
 ;%0A    %7D%0A

Improve output