
type dump = [`Granule | `Simple | `Records | `NoDump | `Summary]
type ui = [`Gtk | `Console]

let filenames = ref []
let ui = ref `Gtk
let dump = ref `NoDump
let loop = ref false;;
let level = ref 0;;
let flip = ref false;;
let shuffle = ref false;;
let each = ref false;;
let font_size = ref 16;;

let debug = ref false;;
let verbose = ref false;;

let args = [
    "--debug", Arg.Set debug,
    "Turn on debugging output; use this for bug reports!";

    "--dump", Arg.Symbol (["simple"; "records"; "granule"; "summary"],
                          (function s ->
                               dump := (match s with
                                            | "simple" -> `Simple
                                            | "records" -> `Records
                                            | "granule" -> `Granule
                                            | "summary" -> `Summary
                                            |  _ -> failwith "Invalid dump"))),
    "Dump the deck to an alternate format, choose from 'simple', 'records', \
     and 'granule'";

    "--each", Arg.Set each,
    "Cause --dump summary to display per-file stats.";

    "--flip", Arg.Set flip,
    "Flip the front/back of cards.  Separate stats are kept for these.";

    "--font-size", Arg.Set_int font_size,
    "Set the font size for the card view.";
    
    "--level", Arg.Set_int level,
    "Choose the minimum box to start in, defaults to 0";
    
    "--loop", Arg.Set loop, 
    "Automatically choose another box to \
         work in after the starting box is empty.";
    
    "--shuffle", Arg.Set shuffle,
    "Before starting each level, shuffle the cards in that level.";
    
    "--ui", Arg.Symbol (["gtk"; "console"],
                        (function s ->
                             ui := (match s with
                                        | "gtk" -> `Gtk
                                        | "console" -> `Console
                                        | _ -> failwith "Invalid UI."))),
    "Choose your ui from: console or gtk";

    "--verbose", Arg.Set verbose,
    "Turn on verbose output, a subset of the debug output.";
    
]




let load_from_file filename = () (* TODO, once I have something to config *)

let load_from_argv usage =
    Arg.parse args 
        (fun filename -> filenames := filename :: !filenames)
        usage;
    filenames := List.rev !filenames
