<commit_before>/*
 * Copyright (C) 2017 CenturyLink, Inc.
 *
 * 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.centurylink.mdw.cli;

import com.beust.jcommander.JCommander;
import com.beust.jcommander.ParameterException;
import com.beust.jcommander.Parameters;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main {

    private static Map<String,Operation> operations = new HashMap<>();
    private static JCommander.Builder builder = JCommander.newBuilder();

    private static void addOperation(String name, Operation operation) {
        operations.put(name, operation);
        builder.addCommand(name, operation);
    }

    public static void main(String[] args) throws IOException {

        // this trimming is necessary on linux
        List<String> cmdArgs = new ArrayList<>();
        for (int i = 0; i < args.length; i++)
            cmdArgs.add(args[i].trim());

        if (cmdArgs.isEmpty()) {
            new Version().run();
        }
        else if ("git".equals(cmdArgs.get(0))) {
            if ("--dependencies".equals(cmdArgs.get(cmdArgs.size() - 1)))
                downloadDependencies(Git.getDependencies(), getMonitor(true));
            else
                Git.main(cmdArgs.toArray(new String[]{})); // git pass-through command
            return;
        }

        Main main = new Main();
        Help help = new Help();
        builder.addObject(main).addCommand(help);
        addOperation("init", new Init());
        addOperation("import", new Import());
        addOperation("update", new Update());
        addOperation("install", new Install());
        addOperation("run", new Run());
        addOperation("stop", new Stop());
        addOperation("version", new Version());
        addOperation("git", new Git());
        addOperation("status", new Status());
        addOperation("test", new Test());
        addOperation("convert", new Convert());<commit_msg>cli fix<commit_after>/*
 * Copyright (C) 2017 CenturyLink, Inc.
 *
 * 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.centurylink.mdw.cli;

import com.beust.jcommander.JCommander;
import com.beust.jcommander.ParameterException;
import com.beust.jcommander.Parameters;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main {

    private static Map<String,Operation> operations = new HashMap<>();
    private static JCommander.Builder builder = JCommander.newBuilder();

    private static void addOperation(String name, Operation operation) {
        operations.put(name, operation);
        builder.addCommand(name, operation);
    }

    public static void main(String[] args) throws IOException {

        // this trimming is necessary on linux
        List<String> cmdArgs = new ArrayList<>();
        for (int i = 0; i < args.length; i++)
            cmdArgs.add(args[i].trim());

        if (cmdArgs.size() == 1 && cmdArgs.get(0).equals("--dependencies")) {
            return;
        }
        else if (cmdArgs.isEmpty() || (cmdArgs.size() == 1 && cmdArgs.get(0).isEmpty())) {
            new Version().run();
            System.out.println("Enter 'mdw help' for usage information");
            return;
        }
        else if ("git".equals(cmdArgs.get(0))) {
            if ("--dependencies".equals(cmdArgs.get(cmdArgs.size() - 1)))
                downloadDependencies(Git.getDependencies(), getMonitor(true));
            else
                Git.main(cmdArgs.toArray(new String[]{})); // git pass-through command
            return;
        }

        Main main = new Main();
        Help help = new Help();
        builder.addObject(main).addCommand(help);
        addOperation("init", new Init());
        addOperation("import", new Import());
        addOperation("update", new Update());
        addOperation("install", new Install());
        addOperation("run", new Run());
        addOperation("stop", new Stop());
        addOperation("version", new Version());
        addOperation("git", new Git());
        addOperation("status", new Status());
        addOperation("test", new Test());
        addOperation("convert", new Convert());
{'fraction_non_alphanumeric': 0.12674726105024556, 'fraction_numerical': 0.004911220249338874, 'mean_word_length': 2.919319022945966, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6639689', 'n_tokens_mistral': 1401, 'n_tokens_neox': 1363, 'n_words': 442}