<commit_before>/*
 *
 * *********************************************************************
 * fsdevtools
 * %%
 * Copyright (C) 2016 e-Spirit AG
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * *********************************************************************
 *
 */

package com.espirit.moddev.cli.configuration;

import com.espirit.moddev.cli.CliConstants;
import com.espirit.moddev.cli.Environment;
import com.espirit.moddev.cli.SyncDirectoryFactory;
import com.espirit.moddev.cli.api.FsConnectionMode;
import com.espirit.moddev.cli.api.configuration.Config;
import com.github.rvesse.airline.annotations.Option;
import com.github.rvesse.airline.annotations.OptionType;
import com.github.rvesse.airline.annotations.restrictions.AllowedRawValues;
import com.github.rvesse.airline.annotations.restrictions.Port;
import com.github.rvesse.airline.annotations.restrictions.PortType;

import de.espirit.firstspirit.access.project.ProjectScriptContext;
import de.espirit.firstspirit.io.FileHandle;
import de.espirit.firstspirit.io.FileSystem;
import de.espirit.firstspirit.io.FileSystemsAgent;

/**
 * A configuration class for a common configuration in a FirstSpirit environment.
 * Some getters return the value of a corresponding environment variable, if the provided
 * value is empty or no value is provided at all.
 *
 * @author e-Spirit AG
 */
public class GlobalConfig implements Config {

    /**
     * {@link de.espirit.firstspirit.access.project.ProjectScriptContext} used by this configuration.
     */
    protected ProjectScriptContext context;

    /**
     * Boolean flag that indicates if the synchronization directory should be created if it does not exist.
     */
    @Option(type = OptionType.GLOBAL, name = {"--dont-create-sync-dir"}, description = "Do not create synchronisation directory if it is missing")
    protected boolean dontCreateSynchronizationDirectoryIfMissing;

    private final Environment environment = new Environment();

    @Option(type = OptionType.GLOBAL, name = "-e", description = "Error mode. Shows error stacktraces.")
    private boolean error;

    @Option(type = OptionType.GLOBAL, name = {"-h", "--host"}, description = "FirstSpirit host. Default is localhost.")
    private String host;

    @Option(type = OptionType.GLOBAL, name = {"-c", "--conn-mode"}, description = "FirstSpirit connection mode. Default is HTTP.")
    @AllowedRawValues(allowedValues = {"HTTP", "SOCKET"})
    private FsConnectionMode fsMode;

    @Option(type = OptionType.GLOBAL, name = {"-port"}, description = "FirstSpirit host's port. Default is 8000.")
    @Port(acceptablePorts = {PortType.SYSTEM, PortType.USER})
    private Integer port;

    @Option(type = OptionType.GLOBAL, name = {"-u", "--user"}, description = "FirstSpirit user. Default is Admin.")
    private String user;

    @Option(type = OptionType.GLOBAL, name = {"-pwd", "--password"}, description = "FirstSpirit user's password. Default is Admin.")
    private String password;

    @Option(type = OptionType.GLOBAL, name = {"-p", "--project"}, description = "Name of FirstSpirit project")<commit_msg>DEVEX-55 removed port limitation<commit_after>/*
 *
 * *********************************************************************
 * fsdevtools
 * %%
 * Copyright (C) 2016 e-Spirit AG
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * *********************************************************************
 *
 */

package com.espirit.moddev.cli.configuration;

import com.espirit.moddev.cli.CliConstants;
import com.espirit.moddev.cli.Environment;
import com.espirit.moddev.cli.SyncDirectoryFactory;
import com.espirit.moddev.cli.api.FsConnectionMode;
import com.espirit.moddev.cli.api.configuration.Config;
import com.github.rvesse.airline.annotations.Option;
import com.github.rvesse.airline.annotations.OptionType;
import com.github.rvesse.airline.annotations.restrictions.AllowedRawValues;
import com.github.rvesse.airline.annotations.restrictions.Port;
import com.github.rvesse.airline.annotations.restrictions.PortType;

import de.espirit.firstspirit.access.project.ProjectScriptContext;
import de.espirit.firstspirit.io.FileHandle;
import de.espirit.firstspirit.io.FileSystem;
import de.espirit.firstspirit.io.FileSystemsAgent;

/**
 * A configuration class for a common configuration in a FirstSpirit environment.
 * Some getters return the value of a corresponding environment variable, if the provided
 * value is empty or no value is provided at all.
 *
 * @author e-Spirit AG
 */
public class GlobalConfig implements Config {

    /**
     * {@link de.espirit.firstspirit.access.project.ProjectScriptContext} used by this configuration.
     */
    protected ProjectScriptContext context;

    /**
     * Boolean flag that indicates if the synchronization directory should be created if it does not exist.
     */
    @Option(type = OptionType.GLOBAL, name = {"--dont-create-sync-dir"}, description = "Do not create synchronisation directory if it is missing")
    protected boolean dontCreateSynchronizationDirectoryIfMissing;

    private final Environment environment = new Environment();

    @Option(type = OptionType.GLOBAL, name = "-e", description = "Error mode. Shows error stacktraces.")
    private boolean error;

    @Option(type = OptionType.GLOBAL, name = {"-h", "--host"}, description = "FirstSpirit host. Default is localhost.")
    private String host;

    @Option(type = OptionType.GLOBAL, name = {"-c", "--conn-mode"}, description = "FirstSpirit connection mode. Default is HTTP.")
    @AllowedRawValues(allowedValues = {"HTTP", "SOCKET"})
    private FsConnectionMode fsMode;

    @Option(type = OptionType.GLOBAL, name = {"-port"}, description = "FirstSpirit host's port. Default is 8000.")
    private Integer port;

    @Option(type = OptionType.GLOBAL, name = {"-u", "--user"}, description = "FirstSpirit user. Default is Admin.")
    private String user;

    @Option(type = OptionType.GLOBAL, name = {"-pwd", "--password"}, description = "FirstSpirit user's password. Default is Admin.")
    private String password;

    @Option(type = OptionType.GLOBAL, name = {"-p", "--project"}, description = "Name of FirstSpirit project")
{'fraction_non_alphanumeric': 0.1439888811674774, 'fraction_numerical': 0.003613620569840167, 'mean_word_length': 4.414597441685478, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5741481', 'n_tokens_mistral': 1965, 'n_tokens_neox': 1900, 'n_words': 611}