<commit_before>/*
 * Copyright 2012 Red Hat inc. and third party contributors as noted
 * by the author tags.
 * 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.redhat.ceylon.common.config;

import com.redhat.ceylon.common.tool.Argument;
import com.redhat.ceylon.common.tool.Description;
import com.redhat.ceylon.common.tool.RemainingSections;
import com.redhat.ceylon.common.tool.Summary;
import com.redhat.ceylon.common.tool.Tool;

@Summary("Manages Ceylon configuration files")
@Description(
"Can be used to list, update and remove settings in Ceylon's configuration files."
)
@RemainingSections(
"##EXAMPLE\n" +
"\n" +
"The following would list the settings active from within the current folder:\n" +
"\n" +
"    ceylon config list"
)
public class CeylonConfigTool implements Tool {
    
    private String action;
    
    @Argument(argumentName="action", multiplicity="1")
    public void setAction(String action) {
        this.action = action;
    }

    @Override
    public void run() {
        if ("list".equals(action)) {
            CeylonConfig config = CeylonConfig.get();
            for (String sectionName : config.getSectionNames(null)) {
                String[] names = config.getOptionNames(sectionName);
                if (names != null && names.length > 0) {
                    System.out.println("[" + sectionName + "]");
                    for (String optionName : names) {
                        String[] values = config.getOptionValues(sectionName + "." + optionName);
                        if (values != null) {
                            for (String value : values) {
                                System.out.println(optionName + "=" + value);
                            }
                        }
                    }
                    System.out.println();
                }
            }
        } else {
            System.err.println("Unknown action '" + action + "'");
        }
    }

    public static void main(String[] args) {
        CeylonConfigTool x = new CeylonConfigTool();
        x.action = "list";
        x.run();
    }
    
}<commit_msg>Changed the "action" argument for the Config Tool from String to an enumeration<commit_after>/*
 * Copyright 2012 Red Hat inc. and third party contributors as noted
 * by the author tags.
 * 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.redhat.ceylon.common.config;

import com.redhat.ceylon.common.tool.Argument;
import com.redhat.ceylon.common.tool.Description;
import com.redhat.ceylon.common.tool.RemainingSections;
import com.redhat.ceylon.common.tool.Summary;
import com.redhat.ceylon.common.tool.Tool;

@Summary("Manages Ceylon configuration files")
@Description(
"Can be used to list, update and remove settings in Ceylon's configuration files."
)
@RemainingSections(
"##EXAMPLE\n" +
"\n" +
"The following would list the settings active from within the current folder:\n" +
"\n" +
"    ceylon config list"
)
public class CeylonConfigTool implements Tool {
    
    private ConfigAction action;
    
    public enum ConfigAction { list };
    
    @Argument(argumentName="action", multiplicity="1")
    public void setAction(ConfigAction action) {
        this.action = action;
    }

    @Override
    public void run() {
        if (action == ConfigAction.list) {
            CeylonConfig config = CeylonConfig.get();
            for (String sectionName : config.getSectionNames(null)) {
                String[] names = config.getOptionNames(sectionName);
                if (names != null && names.length > 0) {
                    System.out.println("[" + sectionName + "]");
                    for (String optionName : names) {
                        String[] values = config.getOptionValues(sectionName + "." + optionName);
                        if (values != null) {
                            for (String value : values) {
                                System.out.println(optionName + "=" + value);
                            }
                        }
                    }
                    System.out.println();
                }
            }
        }
    }

    public static void main(String[] args) {
        CeylonConfigTool x = new CeylonConfigTool();
        x.action = ConfigAction.list;
        x.run();
    }
    
}
{'fraction_non_alphanumeric': 0.10013200075429002, 'fraction_numerical': 0.003771450122572129, 'mean_word_length': 2.2321755027422303, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6124738', 'n_tokens_mistral': 1417, 'n_tokens_neox': 1352, 'n_words': 445}