#include "options.ih"

void Options::init()
{
    d_arg = &ArgConfig::instance();
    d_addressesFilename = (*d_arg)[0];
    d_addresses.open(d_addressesFilename);

    d_ccFilename = (*d_arg)[1];
    d_ccFile.open(d_ccFilename);

    chdir("/");                     // first: all actions from the
                                    // root dir.
    openConfig();

    openLog();

    verifyConfig();

    setSpoolPath();                 // see options.h: 0, sets d_spoolPath

    setErrorDirURL();

    d_sendMail = not d_arg->option(0, "no-mail");

    if (not d_sendMail)
        log() << "Sending e-mail is suppressed\n";

    d_spoolZip = d_arg->option(0, "spool-zip");

    d_mailZip = setMailZipAddresses();  // addresses receiving the zip 
    replace(d_mailZip.begin(), d_mailZip.end(), ',', ' ');

    d_pdf = not d_arg->option(0, "no-pdf");

    spoolActions();                 // decide whether to spool or to mail

    setLatexSkeleton();

    setSubject();

    setWorkingDir();

    d_keepDir = d_arg->option(0, "keepdir");

    d_compile = not d_arg->option(0, "no-compilation");

    d_cc =  d_sendMail and not d_arg->option(0, "no-cc");

    if (d_cc)                       // set extra CC address(es)
        d_arg->option(&d_ccAddresses, "cc");

    d_gpg = d_arg->option(0, "gpg");

    d_arg->option(&d_specs, 's');

    d_arg->option(&d_rotate, 'r');

    if (d_arg->option(&d_fromAddress, "from"))  // s-nail's -r (from) option
        d_fromAddress = "-r " + d_fromAddress + ' '; 

    if (d_arg->option(&d_std, "std"))
        d_std = "--std=" + d_std + ' ';

    d_debug = d_arg->option(0, "debug");
}




