<commit_before>/*
 * chrp, an analysis frontend for the Chemharp library
 * Copyright (C) 2015 <NAME>
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/
*/

#include "Help.hpp"
#include "CommandFactory.hpp"

std::string Help::description() const{
    return "Print help and return.";
}

int Help::run(int argc, char** argv){
    if (argc == 1) {
        list_commands();
    } else {
        about(argv[1]);
    }
    return 0;
}

void Help::list_commands() const {
    std::cout << "Use 'chrp help <subcommand>' to get help about one subcommand." ;
    std::cout << std::endl << std::endl;

    const std::string SEP = "    ";
    std::cout << "Available subcommands:" << std::endl;
    for (auto it : COMMANDS()) {
        auto name = it.first;
        auto command = it.second();
        std::cout << SEP << "'" << name << "' " << command->description() << std::endl;
    }
}

void Help::about(const std::string& name) const {
    auto command = get_command(name);<commit_msg>Improve help display<commit_after>/*
 * chrp, an analysis frontend for the Chemharp library
 * Copyright (C) 2015 <NAME>
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/
*/

#include "Help.hpp"
#include "CommandFactory.hpp"

std::string Help::description() const{
    return "Get help about the subcommands.";
}

int Help::run(int argc, char** argv){
    if (argc == 1) {
        list_commands();
    } else {
        about(argv[1]);
    }
    return 0;
}

void Help::list_commands() const {
    std::cout << "Use 'chrp help <subcommand>' to get help about a specific subcommand." ;
    std::cout << std::endl << std::endl;

    const size_t command_width = 10;
    std::cout << "Available subcommands:" << std::endl;
    for (auto it : COMMANDS()) {
        auto name = it.first;
        auto command = it.second();
        std::cout << "  " << name  << std::string(command_width - name.size(), ' ');
        std::cout << command->description() << std::endl;
    }
}

void Help::about(const std::string& name) const {
    auto command = get_command(name);
{'fraction_non_alphanumeric': 0.15364916773367476, 'fraction_numerical': 0.010243277848911651, 'mean_word_length': 3.055363321799308, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3465033', 'n_tokens_mistral': 759, 'n_tokens_neox': 731, 'n_words': 244}