001/*
002 * Stallion Core: A Modern Web Framework
003 *
004 * Copyright (C) 2015 - 2016 Stallion Software LLC.
005 *
006 * This program is free software: you can redistribute it and/or modify it under the terms of the
007 * GNU General Public License as published by the Free Software Foundation, either version 2 of
008 * the License, or (at your option) any later version. This program is distributed in the hope that
009 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
011 * License for more details. You should have received a copy of the GNU General Public License
012 * along with this program.  If not, see <http://www.gnu.org/licenses/gpl-2.0.html>.
013 *
014 *
015 *
016 */
017
018package io.stallion.boot;
019
020import io.stallion.settings.Settings;
021import org.kohsuke.args4j.Option;
022
023import java.util.ArrayList;
024import java.util.List;
025
026
027public class ServeCommandOptions extends CommandOptionsBase {
028
029    @Option(name="-port", usage="The port number to boot the server on")
030    private int port = 8090;
031
032    @Option(name="-localMode", usage="Set to 'false' if you want to simulate a server environment, with bundled assets, logging to file instead of console, etc.")
033    private String localMode = null;
034
035    @Option(name="-noTasks", usage = "Do not execute asynchronous tasks.")
036    private boolean noTasks = false;
037
038
039    @Override
040    public Settings hydrateSettings(Settings settings) {
041        super.hydrateSettings(settings);
042        settings.setEnv(getEnv());
043        settings.setTargetFolder(getTargetPath());
044        settings.setPort(port);
045        settings.setDevMode(isDevMode());
046        if (getLocalMode() != null) {
047            settings.setLocalMode(getLocalMode());
048        }
049        return settings;
050    }
051
052    public int getPort() {
053        return port;
054    }
055
056
057    public void setPort(int port) {
058        this.port = port;
059    }
060
061
062
063    public Boolean getLocalMode() {
064        if (localMode == null) {
065            return null;
066        }
067        return localMode.toLowerCase().equals("true");
068    }
069
070    public void setLocalMode(String localMode) {
071        this.localMode = localMode;
072    }
073
074    public boolean isNoTasks() {
075        return noTasks;
076    }
077
078    public ServeCommandOptions setNoTasks(boolean noTasks) {
079        this.noTasks = noTasks;
080        return this;
081    }
082}