<commit_before>/*
 * Copyright 1&1 Internet AG, https://github.com/1and1/
 *
 * 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 net.oneandone.stool.client.cli;

import com.google.gson.JsonElement;
import net.oneandone.stool.client.Client;
import net.oneandone.stool.client.Globals;
import net.oneandone.sushi.util.Separator;
import net.oneandone.sushi.util.Strings;

import java.util.Map;

public class Status extends InfoCommand {
    public Status(Globals globals) {
        super(globals);
    }

    private static final Separator TAB = Separator.on('\t');

    @Override
    public void doRun(Client client, String clientFilter) throws Exception {
        Map<String, Map<String, JsonElement>> response;

        response = client.list(clientFilter, selected);
        for (Map.Entry<String, Map<String, JsonElement>> stage : response.entrySet()) {
            output(stage.getValue());
        }
    }


    public void output(Map<String, JsonElement> infos) {
        int width;

        width = 0;
        for (String name : infos.keySet()) {
            width = Math.max(width, name.length());
        }
        width += 2;
        for (Map.Entry<String, JsonElement> entry : infos.entrySet()) {
            console.info.print(Strings.times(' ', width - entry.getKey().length()));
            console.info.print(entry.getKey());
            console.info.print(" : ");
            console.info.println(infoToString(entry.getValue()));
        }
    }
}<commit_msg>prefix fix<commit_after>/*
 * Copyright 1&1 Internet AG, https://github.com/1and1/
 *
 * 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 net.oneandone.stool.client.cli;

import com.google.gson.JsonElement;
import net.oneandone.stool.client.Client;
import net.oneandone.stool.client.Globals;
import net.oneandone.sushi.util.Separator;
import net.oneandone.sushi.util.Strings;

import java.util.Collection;
import java.util.Map;

public class Status extends InfoCommand {
    public Status(Globals globals) {
        super(globals);
    }

    private static final Separator TAB = Separator.on('\t');

    @Override
    public void doRun(Client client, String clientFilter) throws Exception {
        Map<String, Map<String, JsonElement>> response;
        boolean withPrefix;
        int prefixWidth;
        String prefix;
        String name;

        response = client.list(clientFilter, selected);
        withPrefix = response.size() != 1;
        prefixWidth = maxWidth(response.keySet());
        for (Map.Entry<String, Map<String, JsonElement>> stage : response.entrySet()) {
            if (withPrefix) {
                name = stage.getKey();
                prefix = Strings.times(' ', prefixWidth - name.length());
                prefix = prefix + "{" + name + "@" + client.getName() + "} ";
            } else {
                prefix = "";
            }
            output(prefix, stage.getValue());
        }
    }

    public void output(String prefix, Map<String, JsonElement> infos) {
        int width;

        width = maxWidth(infos.keySet()) + 2;
        for (Map.Entry<String, JsonElement> entry : infos.entrySet()) {
            console.info.print(prefix);
            console.info.print(Strings.times(' ', width - entry.getKey().length()));
            console.info.print(entry.getKey());
            console.info.print(" : ");
            console.info.println(infoToString(entry.getValue()));
        }
    }

    private static int maxWidth(Collection<String> names) {
        int width;

        width = 0;
        for (String name : names) {
            width = Math.max(width, name.length());
        }
        return width;
    }
}
{'fraction_non_alphanumeric': 0.11530218602657523, 'fraction_numerical': 0.004500642948992713, 'mean_word_length': 2.6835043409629047, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 2, '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': '6201659', 'n_tokens_mistral': 1302, 'n_tokens_neox': 1281, 'n_words': 374}