package org.secondbase.core;

import org.secondbase.core.config.SecondBaseModule;
import org.secondbase.flags.Flag;
import org.secondbase.flags.Flags;

/**
 * Coordination class for SecondBase modules. Handles Flags parsing and cooperation between modules.
 */
public class SecondBase {

    @Flag(
            name = "service-name",
            description = "Name of service"
    )
    public static String serviceName = "";

    @Flag(
            name = "service-environment",
            description = "The environment the service runs in"
    )
    public static String environment = "testing";

    private Flags flags;

    public SecondBase(final String[] args, final SecondBaseModule[] modules)
            throws SecondBaseException{
        this(args, modules, new Flags());
    }

    public SecondBase(
            final String[] args,
            final SecondBaseModule[] modules,
            final Flags customFlags)
            throws SecondBaseException {
        flags = customFlags;
        flags.loadOpts(SecondBase.class);
        for(final SecondBaseModule module : modules) {
            module.load(this);
        }
        flags.parse(args);

        if (flags.helpFlagged()) {
            flags.printHelp(System.out);
            System.exit(0);
        }
        if (flags.versionFlagged()) {
            flags.printVersion(System.out);
            System.exit(0);
        }

        for (final SecondBaseModule module : modules) {
            module.init();
        }
    }

    /**
     * Get Flags instance used by Base.
     * @return {@link Flags} object
     */
    public Flags getFlags() {
        return flags;
    }
}

@@ -629,169 +629,640 @@
     
-public SecondBase(final String%5B%5D args, final SecondBaseModule%5B%5D modules)%0A            throws SecondBaseException%7B%0A        this(args, modules, new Flags());%0A    %7D%0A
+/**%0A     * Initiates SecondBase with a set of %7B@link SecondBaseModule%7D.%0A     * @param args command line arguments to be parsed%0A     * @throws SecondBaseException if a module fails to start%0A     */%0A    public SecondBase(final String%5B%5D args, final SecondBaseModule%5B%5D modules)%0A            throws SecondBaseException%7B%0A        this(args, modules, new Flags());%0A    %7D%0A%0A    /**%0A     * Initiates SecondBase with a set of %7B@link SecondBaseModule%7D and custom %7B@link Flags%7D.%0A     * @param args command line arguments to be parsed%0A     * @param flags preloaded %7B@link Flags%7D%0A     * @throws SecondBaseException if a module fails to start%0A     */
 %0A   
@@ -1384,23 +1384,17 @@
 l Flags 
-customF
+f
 lags)%0A  
@@ -1444,16 +1444,21 @@
     
+this.
 flags = 
 cust
@@ -1457,15 +1457,9 @@
 s = 
-customF
+f
 lags

Add javadoc to SecondBase (#47)